Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vault Change Order

5 REPLIES 5
Reply
Message 1 of 6
matthew.greenDLCDJ
316 Views, 5 Replies

Vault Change Order

matthew.greenDLCDJ
Contributor
Contributor

I am trying to do a catch on the Vault Change order, when the user hits submit, I need a validation code to run.  The question comes up how do I identify the Change order selected when the right click is used to move to submit?  And how do I catch the Change order when using the Change Order Dialogue and then hit submit.  The CurrentSelectionSet does not work on the command.

 

Dim vaultObj As ISelection In m_Conn.Context.CurrentSelectionSet

 

 

 

        Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
            vApp = application
            AddHandler application.CommandBegin, AddressOf application_CommandBegin
        End Sub

        Private Sub application_CommandBegin(sender As Object, e As CommandBeginEventArgs)
            Dim m_Conn As Connection = sender.Connection
            If e.CommandId = "CO.Submit" Then
                'do something
            End If
        End Sub

 

 

0 Likes

Vault Change Order

I am trying to do a catch on the Vault Change order, when the user hits submit, I need a validation code to run.  The question comes up how do I identify the Change order selected when the right click is used to move to submit?  And how do I catch the Change order when using the Change Order Dialogue and then hit submit.  The CurrentSelectionSet does not work on the command.

 

Dim vaultObj As ISelection In m_Conn.Context.CurrentSelectionSet

 

 

 

        Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
            vApp = application
            AddHandler application.CommandBegin, AddressOf application_CommandBegin
        End Sub

        Private Sub application_CommandBegin(sender As Object, e As CommandBeginEventArgs)
            Dim m_Conn As Connection = sender.Connection
            If e.CommandId = "CO.Submit" Then
                'do something
            End If
        End Sub

 

 

5 REPLIES 5
Message 2 of 6
Boorda
in reply to: matthew.greenDLCDJ

Boorda
Advocate
Advocate

You could try using the PreInvokeEvents and PostInvokeEvents of the ChangeOrderService.

 

        public void OnLogOn(IApplication application)
        {
            application.Connection.WebServiceManager.ChangeOrderService.PreInvokeEvents += ChangeOrderService_PreInvokeEvents;
            application.Connection.WebServiceManager.ChangeOrderService.PostInvokeEvents += ChangeOrderService_PostInvokeEvents;
        }

 

In your Pre and Post events use the MethodName  parameter to identify the method that Vault is calling to filter out what you want to handle, in your case "StartChangeOrderActivity" and "CommitChangeOrderActivity" would probably be what you're looking for.

        private void ChangeOrderService_PreInvokeEvents(object sender, WebServiceInvokeEventArgs e)
        {
            switch (e.MethodName)
            {
                case "StartChangeOrderActivity":
                    /* Do some stuff before the call..  */
                    break;

                case "CommitChangeOrderActivity":
                    /* Do some stuff before the call..  */
                    break;
            }
        }

        private void ChangeOrderService_PostInvokeEvents(object sender, WebServiceInvokeEventArgs e)
        {

            switch (e.MethodName)
            {
                case "StartChangeOrderActivity":
                    /* Do some stuff after the call..  */
                    break;

                case "CommitChangeOrderActivity":
                    /* Do some stuff after the call..  */
                    break;
            }

        }

 

StartChangeOrderActivity and CommitChangeOrderActivity get called on any change order activity, so you'll want to use the e.Parameters property to further filter down to the exact state you want to handle by its ID.

 

Double check this, but I think the parameters always in the following order:
[0] Change Order ID

[1] To State ID

[2] From State ID

[3] Creation Date (Only populated after moving to Work state, I think?)

Boorda_0-1676315098568.png

 

Hope that at least points you in the right direction.




Automation is key!
0 Likes

You could try using the PreInvokeEvents and PostInvokeEvents of the ChangeOrderService.

 

        public void OnLogOn(IApplication application)
        {
            application.Connection.WebServiceManager.ChangeOrderService.PreInvokeEvents += ChangeOrderService_PreInvokeEvents;
            application.Connection.WebServiceManager.ChangeOrderService.PostInvokeEvents += ChangeOrderService_PostInvokeEvents;
        }

 

In your Pre and Post events use the MethodName  parameter to identify the method that Vault is calling to filter out what you want to handle, in your case "StartChangeOrderActivity" and "CommitChangeOrderActivity" would probably be what you're looking for.

        private void ChangeOrderService_PreInvokeEvents(object sender, WebServiceInvokeEventArgs e)
        {
            switch (e.MethodName)
            {
                case "StartChangeOrderActivity":
                    /* Do some stuff before the call..  */
                    break;

                case "CommitChangeOrderActivity":
                    /* Do some stuff before the call..  */
                    break;
            }
        }

        private void ChangeOrderService_PostInvokeEvents(object sender, WebServiceInvokeEventArgs e)
        {

            switch (e.MethodName)
            {
                case "StartChangeOrderActivity":
                    /* Do some stuff after the call..  */
                    break;

                case "CommitChangeOrderActivity":
                    /* Do some stuff after the call..  */
                    break;
            }

        }

 

StartChangeOrderActivity and CommitChangeOrderActivity get called on any change order activity, so you'll want to use the e.Parameters property to further filter down to the exact state you want to handle by its ID.

 

Double check this, but I think the parameters always in the following order:
[0] Change Order ID

[1] To State ID

[2] From State ID

[3] Creation Date (Only populated after moving to Work state, I think?)

Boorda_0-1676315098568.png

 

Hope that at least points you in the right direction.




Automation is key!
Tags (1)
Message 3 of 6
matthew.greenDLCDJ
in reply to: Boorda

matthew.greenDLCDJ
Contributor
Contributor

I went another direction.  But having trouble when the ChangeOrder changes it fires UpdateFileLifecycleStateEvents_GetRestrictions twice and then the Post twice also.  Cannot Identify why it is doubling.  Any thoughts.

 Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
        AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.GetRestrictions, AddressOf UpdateChangeOrderLifeCycleStateEvents_GetRestrictions
        AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.Post, AddressOf UpdateFileLifecycleStateEvents_Post
    End Sub

    Public Sub UpdateChangeOrderLifeCycleStateEvents_GetRestrictions(ByVal s As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
        If s.GetChangeOrdersByIds({e.ChangeOrderId})(0).statename = "Open" Then 'Submit to Work
            CheckChangeOrderFilesForState(s, e, "Work", "Release") 'Special Case
        End If
    End Sub
    Sub CheckChangeOrderFilesForState(s As Object, ByVal eventArgs As UpdateChangeOrderLifeCycleStateCommandEventArgs, ECOnewState As String, FileStateCheck As String)

        If IsNothing(webMgr) Then
            webMgr = s.WebServiceManager
        End If

        Dim oFileIds() As Long = webMgr.ChangeOrderService.GetAssociationsByChangeOrderIDs({eventArgs.ChangeOrderId}, EntityClassIds.Files)(0).EntIdArray

        For Each ofile As ACW.File In webMgr.DocumentService.GetFilesByIds(oFileIds)
            If ofile.FileLfCyc.LfCycStateName <> FileStateCheck And ofile.FileLfCyc.LfCycStateName <> "Release" Then
                eventArgs.AddRestriction(New ExtensionRestriction(oChangeOrder.Num, String.Format("The Change Order cannot be ""{0}"" because all of the files are not in" & " the ""{1}"" state.", ECOnewState, FileStateCheck)))
                GoTo exitSub
            End If
        Next
exitSub:
    End Sub
    Sub UpdateFileLifecycleStateEvents_Post(ByVal sender As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
        Dim msgForm As New msgBuilder
        msgBuilder.ShowDialog()
        msgBuilder.Close()
    End Sub

  

0 Likes

I went another direction.  But having trouble when the ChangeOrder changes it fires UpdateFileLifecycleStateEvents_GetRestrictions twice and then the Post twice also.  Cannot Identify why it is doubling.  Any thoughts.

 Public Sub OnStartup(application As IApplication) Implements IExplorerExtension.OnStartup
        AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.GetRestrictions, AddressOf UpdateChangeOrderLifeCycleStateEvents_GetRestrictions
        AddHandler ChangeOrderService.UpdateChangeOrderLifecycleStateEvents.Post, AddressOf UpdateFileLifecycleStateEvents_Post
    End Sub

    Public Sub UpdateChangeOrderLifeCycleStateEvents_GetRestrictions(ByVal s As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
        If s.GetChangeOrdersByIds({e.ChangeOrderId})(0).statename = "Open" Then 'Submit to Work
            CheckChangeOrderFilesForState(s, e, "Work", "Release") 'Special Case
        End If
    End Sub
    Sub CheckChangeOrderFilesForState(s As Object, ByVal eventArgs As UpdateChangeOrderLifeCycleStateCommandEventArgs, ECOnewState As String, FileStateCheck As String)

        If IsNothing(webMgr) Then
            webMgr = s.WebServiceManager
        End If

        Dim oFileIds() As Long = webMgr.ChangeOrderService.GetAssociationsByChangeOrderIDs({eventArgs.ChangeOrderId}, EntityClassIds.Files)(0).EntIdArray

        For Each ofile As ACW.File In webMgr.DocumentService.GetFilesByIds(oFileIds)
            If ofile.FileLfCyc.LfCycStateName <> FileStateCheck And ofile.FileLfCyc.LfCycStateName <> "Release" Then
                eventArgs.AddRestriction(New ExtensionRestriction(oChangeOrder.Num, String.Format("The Change Order cannot be ""{0}"" because all of the files are not in" & " the ""{1}"" state.", ECOnewState, FileStateCheck)))
                GoTo exitSub
            End If
        Next
exitSub:
    End Sub
    Sub UpdateFileLifecycleStateEvents_Post(ByVal sender As Object, ByVal e As UpdateChangeOrderLifeCycleStateCommandEventArgs)
        Dim msgForm As New msgBuilder
        msgBuilder.ShowDialog()
        msgBuilder.Close()
    End Sub

  

Message 4 of 6
Boorda
in reply to: matthew.greenDLCDJ

Boorda
Advocate
Advocate

I use Fiddler a lot to track Vault API calls and I can tell you the double calling seems to be a very common occurrence. My only assumption is that it could be somehow related to the pre and post events, but to me the call should still only happen once; especially on a method that posts changes to the server. Sorry I don't have more of an answer on this one.


Automation is key!
0 Likes

I use Fiddler a lot to track Vault API calls and I can tell you the double calling seems to be a very common occurrence. My only assumption is that it could be somehow related to the pre and post events, but to me the call should still only happen once; especially on a method that posts changes to the server. Sorry I don't have more of an answer on this one.


Automation is key!
Message 5 of 6
matthew.greenDLCDJ
in reply to: Boorda

matthew.greenDLCDJ
Contributor
Contributor

Thank you, never used Fiddler before but seems very powerful and helpful.  I am looking forward to trying to use it with Vault and Programming.   Even with Fiddler I cannot seem to find out why the call is doing a double call.  Thank you for your help.  I am just going to have to do a workaround somehow. 

Thank you, never used Fiddler before but seems very powerful and helpful.  I am looking forward to trying to use it with Vault and Programming.   Even with Fiddler I cannot seem to find out why the call is doing a double call.  Thank you for your help.  I am just going to have to do a workaround somehow. 

Message 6 of 6
Boorda
in reply to: matthew.greenDLCDJ

Boorda
Advocate
Advocate

Won't really help you with this issue, but if you're interested in using Fiddler for future Vault development, I'm creating a Fiddler extension that helps track info about Vault API calls. It's still in development, but I can post a link here once it's done. It will be free to use and will only be supported via donations.

VaultRequest_Fiddler.png



Automation is key!
0 Likes

Won't really help you with this issue, but if you're interested in using Fiddler for future Vault development, I'm creating a Fiddler extension that helps track info about Vault API calls. It's still in development, but I can post a link here once it's done. It will be free to use and will only be supported via donations.

VaultRequest_Fiddler.png



Automation is key!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report