Compartilhar via


Implementing entity ID filtering

When using the "GetByKey" operations for the Dynamics GP service, be sure to check the Dynamics GP Web Service Reference help file to verify which operations can be affected by the entity ID filtering. The administrator for the Dynamics GP web service may have assigned roles that cause the entity ID assignments to be used. Your application must be able to handle any exceptions that occur when the web service administrator assigns one of the restricted operations. For instance, the application must handle cases where no entity ID assignment was found for the current user.

The "GetList" operations that support entity ID filtering have a Scope property for the selection criteria that specifies which objects are returned. The Scope property can be set to return all objects, which is the default behavior. It can also be set to return only those objects that match the specific type of entity ID assigned to the current user.

For example, the CustomerCriteria object supports entity ID filtering, so it contains the Scope property. This property can be set to "Return All" to return all customers. It can be set to "Return Based on Customer Id" to return the customer with an ID that matches the Customer ID assigned to the current user. It can also be set to "Return Based on Salesperson Id" to return the customers that have the Salesperson ID that matches the Salesperson ID assigned to the current user.

Hint: If a Windows User ID is assigned to multiple entity IDs in Microsoft Dynamics GP, the GetList operation will return values for each of the entities that are mapped.

If you use the entity ID filtering for GetList operations, be sure to handle the "access denied" exceptions that can occur if the Dynamics GP service administrator hasn't given access to the proper roles. Be sure to document the restricted operations that are required for your application.

Hint: It's a good idea to test your web service applications with the roles that provide full access to service operations and also the restricted roles that implement the entity ID filtering.

If your application uses the WorkOnBehalfOf property for the Context object, be aware that this changes the user for entity ID filtering. The WorkOnBehalfOf user, not the user running the application, will be used for the entity ID filtering.