2 Replies Latest reply on Mar 6, 2014 4:30 PM by Steven Dod

    EPDM task add-in to get and set data card variable

    Steven Dod

      I am working on a task add-in to get and set a data card variable.  I have done this using a windows forms application but I am trying to make this work as an add-in that starts from the context menu.  The task is shown on the menu and does not generate any errors but it basically does nothing at all.  I have trimmed the add-in down to the bare minimum tryng to get it to display the value from the data card.  I have tried to find some more info on using "IEdmEnumeratorVariable5" with "poCmd.mpoExtra" but cannot seemd to find exactly what I am looking for.  Since there are no errors I cannot tell what is or is not going on. (and yes "Part Number" is a valid variable on the card)



        • Re: EPDM task add-in to get and set data card variable
          Jim Sculley

          For a context menu command, the mpoExtra field is not used and will always be null (or Nothing in VB).  The only time the mpoExtra field will contain an IEdmEnumeratorVariable object is when OnCmd is called as a result of a data card button being pressed or a data field on a card is changed. 


          In all other cases, the file-specific data is contained in the array of EdmCmdData passed in as the second argument to OnCmd.  For a context menu item selection, the EdmCmdData object for each file will contain 4 values, as stated in the API help for EdmCmdData:




          ID of file (or zero if a folder is selected).



          ID of folder (or zero if a file is selected).



          ID of parent folder of the selected file or folder.



          Name of file or folder. (Only the name, not a full path.)


          So, you typically would loop through the EdmCmdData array, using IEdmVault::GetObject (passing in the value of mlObjectID1) to get the IEdmFile object and then calling IEdmFile::GetEnumeratorVariable.  Then you can call GetVar/SetVar to view or change the data.  Read the SetVar documentation closely.  You have to remember to call Flush or CloseFile to make sure you don't cause sharing violations.


          If you have to update multiple files, the preferred method is to use the IEdmBatchUpdate2 object.


          Jim S.