Web Services - code to retrieve a PO

This article contains code to retrieve a PO document using Web Services for Dynamics GP 2015

 

Related Articles

... and you 'll find more on the Web Services Menu

 

Function GetPO() As PurchaseOrder
       ' Create an instance of the service
       Dim wsDynamicsGP As DynamicsGPClient = New DynamicsGPClient()
       Dim oExistingPO As PurchaseOrder
 
       Try
           Dim companyKey As CompanyKey
           Dim context As Context
           Dim purchaseOrderKey As PurchaseTransactionKey
 
           ' 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)
 
           ' Create a purchase transaction key to identify the purchase order
           purchaseOrderKey = New PurchaseTransactionKey
           purchaseOrderKey.Id = "PO2076"
 
           'retrieve an existing PO
           oExistingPO = wsDynamicsGP.GetPurchaseOrderByKey(purchaseOrderKey, context)
 
       Catch ex As System.ServiceModel.FaultException(Of System.ServiceModel.ExceptionDetail)
           Throw ex
       Catch ex As System.ServiceModel.FaultException
           Throw ex
       Catch ex As Exception
           Throw ex
       End Try
 
       ' Close the service
       If wsDynamicsGP.State <> CommunicationState.Faulted Then
           wsDynamicsGP.Close()
       End If
 
       Return oExistingPO
   End Function
 

 


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