Share via


Dynamics GP service use for Sales Documents

The sample application uses several Dynamics GP service objects and methods. The sample also contains code to make the application tenant-aware. The DataManagement class loads a proxy class named wsDynamicsGP that allows service objects and methods to be used. The application loads the wsDynamicsGP proxy class using information provided by the service.

Tenant support

When the CustomerSalesForm is loaded, a helper routine is called to find out whether the application is accessing a multitenant installation of Microsoft Dynamics GP. The helper uses the MultitenantEnabled() method of the Dynamics GP service to find this information. If multitenant functionality is enabled, the GetTenantList() method retrieves the list of tenants the user has access to. If the user has access to more than one tenant, a list of the tenants is displayed to allow the user to select the tenant they want to acess. The name of the selected tenant is stored to be used for the Context object.

Web Methods

The DataManagement class constructor creates the service proxy and creates a context object.

The GetCompanyList method retrieves the list of all available companies. The method uses a CompanyCriteria object along with a BetweenRestrictionOfNullableOfint restriction object to retrieve a list of company summary objects.

The GetCustomerList method retrieves a list of customers for a specified company. The company is designated by setting the OrganizationKey property of the Context object. The method uses a CustomerCriteria object and a LikeRestrictionOfstring object to retrieve the list of customer summary objects.

The GetSalesDocumentListAsync method retrieves a list of sales documents for the specified customer. The method uses a SalesDocumentCriteria object with a ListRestrictionOfNullableOfSalesDocumentType restriction object and a LikeRestrictionOfstring object to retrieve the requested sales document summary objects. The asynchronous method ensures the user interface remains responsive even when retrieving the sales document list becomes a lengthy operation.

A GetSalesDocumentListCompletedEventHandler object specifies the method that receives the service response to the asynchronous GetSalesDocumentListAsync method. The method wsDynamics GP_GetSalesDocumentListCompleted places the data supplied by the service into a dataset and updates the user interface data grid.