Share via


Organization key

The organization key property of the Conext object specifies the company in Microsoft Dynamics GP that the method should be performed in. Specifying the company allows the Dynamics GP service to perform requests in the correct company database in SQL Server. The value corresponds to the numeric Company ID value in Microsoft Dynamics GP. The following C# example demonstrates setting the OrganizationKey property.

// Create a context with which to call the web service
context = new Context();

// Specify which company
companyKey = new CompanyKey();
companyKey.Id = 1;

// Set up the context
context.OrganizationKey = companyKey;

If the web method is to be performed in the context of the system (DYNAMICS database) then the OrganizationKey should be set to null.