5 Replies Latest reply on Jan 5, 2015 7:04 AM by Jim Sculley

    EPDM API: Accessing Properties of File in Transition

    Sean O'Neill

      Greetings, API Community --

       

      I'm wondering how most of you typically go about accessing properties of a file en route through a workflow transition. For example, I plan on using 'Execute command' as an action during the transition to call on a program I'm writing. Here are my thoughts on how this would work:

       

      1) User puts file through transition manually

      2) Execute command is triggered as an 'Action' in the transition, launching a program silently

      3) Program somehow accesses file object to retrieve properties pertinent to program

       

      Many of the examples in the help show you how to use the API to access properties of a file you manually browse to. In this case, I want to automatically access the file name of the component in the transition without browsing to it through a VB.NET-based UI. Any ideas on how to approach this code-wise?

       

      Cheers,
      Sean

        • Re: EPDM API: Accessing Properties of File in Transition
          Jim Sculley

          Rather than use Execute Command, why not make an add-in and simply watch for the state change using the IEdmCmdMgr::AddHook method and act accordingly.  When the OnCmd method of your add-in is called in response to the state change, you will be passed a structure containing the file IDs of all the files involved and once you have the ID, you can access all the other information you need.

           

          Jim S.

          • Re: EPDM API: Accessing Properties of File in Transition
            Sean O'Neill

            Hey Jim/All,

             

            I believe I'm on the right track here, but I'm having some difficulty capturing variables from the part in transition.

             

            ---------------------

             

            Dim AffectedFile As EdmCmdData

            Dim AffectedFileNames As String = vbCrLf + vbCrLf

            Dim CurCmdData As EdmCmdData = ppoData(0)

            Dim mbsStrData2 As String = CurCmdData.mbsStrData2

            Dim vars As IEdmEnumeratorVariable5 = poCmd.mpoExtra

             

                    'For example, if a file is about to be checked out:

                    Select Case poCmd.meCmdType

                        Case EdmCmdType.EdmCmd_PreState And mbsStrData2 = "Released"

                            For Each AffectedFile In ppoData

                                AffectedFileNames += AffectedFile.mbsStrData1 + vbCrLf

                            Next AffectedFile

                            AffectedFileNames += vbCrLf

                            'Directly below is an attempt to take the SQL output mock string.

                            Dim sqlValue As Object = Nothing

                            Dim GetVarSuccess As Boolean

                            GetVarSuccess = vars.GetVar("sqloutput", "@", sqlValue)

                            sqlValue += vbCrLf

                            Dim MsgBoxResult1 As MsgBoxResult

                            MsgBoxResult1 = MsgBox("The file below will serve as the source for exported files" + AffectedFileNames + "Below is the SQL String:" + sqlValue, MsgBoxStyle.OkOnly)

             

            -------------------

             

            I'm not confident that I'm making an adequate attempt to access the variable info contained in the card variable 'sqloutput'. I've tried this on SolidWorks files where sqloutput has a value input in the '@' configuration on its datacard. I want to retrieve this string value for use elsewhere. Any thoughts on why this might not be working? I'm receiving a 0x080004003 error saying that an invalid pointer was supplied to the method.

             

            Thanks!