Web Services - Update a SOP Document

This is a code example that shows how to update a SOP document. The technique is to first retreive the document, then update it. This example uses the GP2010 native entpoint.

 

Imports WebServicesGP2010.ServiceReference1
Imports System.ServiceModel
  
Public Class Form1
  
    Private Sub UpdateSOPDoc()
        Dim companyKey As CompanyKey
        Dim context As Context
  
        Dim salesOrderKey As SalesDocumentKey
        Dim salesOrder As SalesOrder
        Dim salesOrderUpdatePolicy As Policy
  
  
  
        ' Create an instance of the service
        Dim wsDynamicsGP As DynamicsGPClient = New DynamicsGPClient
        ' Create a context with which to call the service
  
        context = New Context
        ' Specify which company to use (sample company)
        companyKey = New CompanyKey
        companyKey.Id = -1
        ' Set up the context object
        context.OrganizationKey = CType(companyKey, OrganizationKey)
  
        salesOrderKey = New SalesDocumentKey
        salesOrderKey.Id = "ORDST2227"
        ' Retrieve the sales order
        salesOrder = wsDynamicsGP.GetSalesOrderByKey(salesOrderKey, context)
  
        ' Retrieve the update policy for sales orders
        salesOrderUpdatePolicy = wsDynamicsGP.GetPolicyByOperation("UpdateSalesOrder", context)
  
        ' Set the comment property
        salesOrder.Comment = "Customer notified - March 17"
        ' Update the sales order object UpdateSalesDocument:
        Try
            wsDynamicsGP.UpdateSalesOrder(salesOrder, context, salesOrderUpdatePolicy)
            ' Close the service
            If wsDynamicsGP.State <> CommunicationState.Faulted Then
                wsDynamicsGP.Close()
            End If
  
        Catch ex As Exception
            MsgBox(ex)
        End Try
  
    End Sub
End Class

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences