Retrieves the policy instance based on the key value (GUID) for the policy and the role key supplied. The returned policy object will contain both the internal and the external behaviors.
Parameter |
Type |
Description |
---|---|---|
key |
The policy key object ths specifies the policy to retrieve. |
|
roleKey |
The role key object that specifies the role for the policy instance. |
|
context |
Specifies information about how the method will be called. |
Value |
Type |
Description |
---|---|---|
GetCompletePolicyByKeyResult |
The policy instance object. |
The following C# example retrieves the default instance of the Update Sales Return policy. The GUID for the Update Sales Return policy was found in the Policy Reference for the Dynamics GP service. The role key object specifies the default policy instance. The total number of behaviors for the policy is displayed in a message box.
Legacy endpoint
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; PolicyKey policyKey; Policy salesReturnPolicy; RoleKey roleKey; // Create an instance of the service DynamicsGP wsDynamicsGP = new DynamicsGP(); // Be sure that default credentials are 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 object context.OrganizationKey = (OrganizationKey)companyKey; // Create the role key for the default role roleKey = new RoleKey(); roleKey.Id = "00000000-0000-0000-0000-000000000000"; // Get the complete update policy for sales returns policyKey = new PolicyKey(); policyKey.Id = new Guid("a08b0c69-13bd-4a7b-bda9-d7902803364b"); salesReturnPolicy = wsDynamicsGP.GetCompletePolicyByKey(policyKey, roleKey, context); MessageBox.Show(salesReturnPolicy.Behaviors.Length.ToString()); } } }
Native endpoint
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; PolicyKey policyKey; Policy salesReturnPolicy; RoleKey roleKey; // Create an instance of the service DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(); // 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 = (OrganizationKey)companyKey; // Create the role key for the default role roleKey = new RoleKey(); roleKey.Id = "00000000-0000-0000-0000-000000000000"; // Get the complete update policy for sales returns policyKey = new PolicyKey(); policyKey.Id = new Guid("a08b0c69-13bd-4a7b-bda9-d7902803364b"); salesReturnPolicy = wsDynamicsGP.GetCompletePolicyByKey(policyKey, roleKey, context); MessageBox.Show(salesReturnPolicy.Behaviors.Length.ToString()); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }