1 Reply Latest reply on Jun 10, 2015 11:51 PM by Tim Webb

    How to get Transition Name from poCmd in AddHook?

    Edwin Chung

      Looking for some advice - I'm sure this is in the API guide, but I was having trouble finding it. There's a brief piece of code, below.

       

      How do I retrieve the Name of the Transition State (e.g. "Submit for Approval" or "Release Documents" or "Reject Changes")?

       

      Public Sub GetAddInInfo(ByRef poInfo As EdmAddInInfo, poVault As IEdmVault5, poCmdMgr As IEdmCmdMgr5) Implements IEdmAddIn5.GetAddInInfo
              ...
              poCmdMgr.AddHook(EdmCmdType.EdmCmd_PreState)
      End Sub
      
      Public Sub OnCmd(ByRef poCmd As EdmCmd, ByRef ppoData As Array) Implements IEdmAddIn5.OnCmd
           Dim vault As IEdmVault14 = poCmd.mpoVault
           Dim eFile As IEdmFile8 = vault.GetObject(EdmObjectType.EdmObject_File, ppoData(index).mlObjectID1)
           Dim myMessage As String = ""
           myMessage = 'the name of the Transition State the file is in?
           MsgBox(myMessage)
      End Sub
      

       

      Thanks!

        • Re: How to get Transition Name from poCmd in AddHook?
          Tim Webb

          Hi Edwin,

           

          I've uploaded this addin as an EPDM export file on our downloads page. Follow the instructions to install the add-in. I recommend using this one in a testbed vault because it returns a messagebox on EVERY transition in EPDM. Hope it helps!

           

          Here's some code to return the transition name:

          Imports EdmLib
          
          Public Class GetTransitionInfo
              Implements IEdmAddIn5
          
              Public Sub GetAddInInfo(ByRef poInfo As EdmLib.EdmAddInInfo, ByVal poVault As EdmLib.IEdmVault5, ByVal poCmdMgr As EdmLib.IEdmCmdMgr5) Implements EdmLib.IEdmAddIn5.GetAddInInfo
                  poInfo.mbsAddInName = "GetTransition"
                  poInfo.mbsCompany = "equivaQ Software, LLC."
                  poInfo.mbsDescription = "Gathers transition info."
                  poInfo.mlAddInVersion = 1000
                  poInfo.mlRequiredVersionMajor = 6
                  poInfo.mlRequiredVersionMinor = 0
                  poCmdMgr.AddHook(EdmCmdType.EdmCmd_PreState)
             End Sub
          
              Public Sub OnCmd(ByRef poCmd As EdmLib.EdmCmd, ByRef ppoData As System.Array) Implements EdmLib.IEdmAddIn5.OnCmd
                  Try
                      If poCmd.meCmdType = EdmCmdType.EdmCmd_PreState Then
                          Dim vault As IEdmVault11 = Nothing 'create a vault object
                          Dim file As IEdmFile5 = Nothing 'create a file object
                          Dim folder As IEdmFolder5 = Nothing 'create a folder object
                          Dim transition As IEdmTransition6 = Nothing 'create a transition object
                          Dim srcstate As IEdmState6 = Nothing 'create a state object
                          Dim deststate As IEdmState6 = Nothing 'create a state object
          
                          Dim Ctr As Integer = 0 'simple counter to iterate through the incoming ppoData array
          
                          vault = poCmd.mpoVault 'set the vault to the incoming vault object
                          For Ctr = 0 To UBound(ppoData) 'loop through the incoming ppoData array
                              'search the API help file for EdmCmdType.EdmCmd_PreState to see what the mlObjectID1, 2, 3 of mlLongData1, 2 are passed to the ppoData array on the PreState hook
                              file = vault.GetObject(EdmObjectType.EdmObject_File, ppoData(Ctr).mlObjectID1) 'set the file object
                              folder = vault.GetObject(EdmObjectType.EdmObject_Folder, ppoData(Ctr).mlObjectID2) 'set the folder object
                              transition = vault.GetObject(EdmObjectType.EdmObject_Transition, ppoData(Ctr).mlobjectid3) 'set the transition object
                              srcstate = vault.GetObject(EdmObjectType.EdmObject_State, ppoData(Ctr).mlLongData1) 'set the source state object
                              deststate = vault.GetObject(EdmObjectType.EdmObject_State, ppoData(Ctr).mlLongData2) 'set the destination state object
                              'post a messagebox showing what values you captured
                              MsgBox("File: " & file.Name & vbNewLine _
                                    & "Folder: " & folder.LocalPath & vbNewLine _
                                    & "Transition name: " & transition.Name & vbNewLine _
                                    & "Source state name: " & srcstate.Name & vbNewLine _
                                    & "Destination state name: " & deststate.Name)
          
                          Next Ctr 'next counter value
                      End If
                  Catch ex As Exception
                      MsgBox("Error in OnCmd: " & ex.Message, MsgBoxStyle.Exclamation)
                  End Try
              End Sub
          End Class
          

          Here are the screens you will see with this test addin

          pre state.bmp

           

          message box.bmp

           

          Enjoy!

          Tim CEPA

          equivaQ Software, LLC

          http://www.equivaq.com