Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Description
Creates a policy instance for the specified role. The new policy instance can have different behavior settings from the default policy for the service operation.
Parameters
Parameter |
Type |
Description |
|---|---|---|
policy |
Specifies the set of behaviors and behavior options to be applied during the operation. |
|
roleKey |
The role key object that specifies the role for which the policy instance is being created. |
|
context |
Specifies information about how the method will be called. |
Interfaces
- Dynamics GP
- Common
- Field Service
- Financials
- Human Resources/Payroll
- Inventory
- Manufacturing
- Project Accounting
- Purchasing
- Sales
Examples
The following C# example creates a policy instance of the Update Sales Return policy for the Sales Representitive role in the sample company Fabrikam.
** Legacy endpoint**
using System;
using System.Collections.Generic;
using System.Text;
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;
// Get the update policy for sales returns
policyKey = new PolicyKey();
policyKey.Id = new Guid("a08b0c69-13bd-4a7b-bda9-d7902803364b");
salesReturnPolicy = wsDynamicsGP.GetPolicyByKey(policyKey, context);
// Create the role key for the new role
roleKey = new RoleKey();
roleKey.Id = "aaeb72e0-77f9-4925-ab9a-73012417fb37";
// Create the new policy instance for sales returns
wsDynamicsGP.CreatePolicy(salesReturnPolicy, roleKey, context);
}
}
}
** Native endpoint **
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
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;
// Get the update policy for sales returns
policyKey = new PolicyKey();
policyKey.Id = new Guid("a08b0c69-13bd-4a7b-bda9-d7902803364b");
salesReturnPolicy = wsDynamicsGP.GetPolicyByKey(policyKey, context);
// Create the role key for the new role
roleKey = new RoleKey();
roleKey.Id = "aaeb72e0-77f9-4925-ab9a-73012417fb37";
// Create the new policy instance for sales returns
wsDynamicsGP.CreatePolicy(salesReturnPolicy, roleKey, context);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}