AddChangeOrder Example?

AddChangeOrder Example?

Anonymous
Not applicable
820 Views
4 Replies
Message 1 of 5

AddChangeOrder Example?

Anonymous
Not applicable

Does anybody have a working example of creating a change order via the API in 2013? (.NET)

I've been playing around but keep getting Soap Exception 106. 

 

Thanks in advance,

Tom

0 Likes
Accepted solutions (1)
821 Views
4 Replies
Replies (4)
Message 2 of 5

minkd
Alumni
Alumni

The 106 error indicates that you are trying to call a method prior to signing-in as a user.

 

-Dave



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hmm, well I thought I was logging in correctly but perhaps not.

Here's what I've got so far:

 

        Dim login As New UserPasswordCredentials("ellisws1", "Routing", "Administrator", "")

        Using serviceManager As New WebServiceManager(login)

            Try
                Dim myeco As ChangeOrderService
                myeco = New ChangeOrderService

                ' get the default routing 
                Dim workflow As Workflow = myeco.GetDefaultWorkflow()
                Dim routings As Routing() = myeco.GetRoutingsByWorkflowId(workflow.Id)
                Dim defaultRouting As Routing = routings.FirstOrDefault(Function(n) n.IsDflt)
                If defaultRouting Is Nothing Then
                    Throw New Exception("No default routing")
                End If

                ' get the next number in the default sequence 
                Dim numberingSchemes As ChangeOrderNumSchm() = _
                    myeco.GetNumberingSchemesByType(NumSchmType.ApplicationDefault)
                Dim defaultNumberingScheme As ChangeOrderNumSchm = numberingSchemes.FirstOrDefault()
                If defaultNumberingScheme Is Nothing Then
                    Throw New Exception("No default numbering scheme")
                End If
                Dim coNumber As String = myeco.GetChangeOrderNumberBySchemeId(defaultNumberingScheme.Id)

                Dim newCo As ChangeOrder = myeco.AddChangeOrder(defaultRouting.Id, coNumber, "test", "testing desc", DateTime.Now.AddMonths(1), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)

            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error creating ECO")
                Return
            End Try

        End Using

 

The 106 error comes from the GetDefaultWorkflow function.

 

Any advice?

Thanks.

 

0 Likes
Message 4 of 5

Redmond.D
Autodesk
Autodesk
Accepted solution

Don't new-up any of the Service objects.  The WebServiceManager takes care of all that.

 

Replace the line

     myeco = New ChangeOrderService

with

     myeco = serviceManager.ChangeOrderService

 

That should get your farther in your code.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 5

Anonymous
Not applicable

Ahhh. That makes sense.

Its working now.

 

Thanks!

0 Likes