Web Services - Get Customer by Key Legacy

This short code example shows how to code the GetCustomerByKey endpoint in Dynamics GP Web Services for GP2010. We use the legacy endpoint here.

Imports WebServicesGP2010.Legacy
 
Public Class GetCustomerByKeyLegacy
    Sub getCustomerByKeyLegacy()
 
        Dim CompanyKey As Legacy.CompanyKey
        Dim Context As Legacy.Context
        Dim Customer As Legacy.Customer
        Dim CustomerKey As Legacy.CustomerKey
 
        ' Create an instance of the service
        'this is the legacy endpoint. You'll find a discussion on Legacy vs Native and how to connect to both here:
        'http://dyndeveloper.com/articleview.aspx?ArticleID=62
        Dim wsDynamicsGP As DynamicsGP = New DynamicsGP
 
        ' Be sure that default credentials are being used
        wsDynamicsGP.UseDefaultCredentials = True
 
        ' 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
        Context.OrganizationKey = CType(CompanyKey, OrganizationKey)
 
        ' Create a customer key
        CustomerKey = New CustomerKey()
        CustomerKey.Id = "AARONFIT0001"
 
        ' Retrieve the customer object
        Customer = wsDynamicsGP.GetCustomerByKey(CustomerKey, Context)
 
        MessageBox.Show(Customer.Name)
    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