Compartilhar via


DeletePolicy

Description

Deletes a policy instance for the specified role.

Parameters

Parameter

Type

Description

policyKey

PolicyKey

The policy key object that specifies the policy for which a policy instance will be deleted.

roleKey

RoleKey

The role key object that specifies the role for the policy instance that is being deleted.

context

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 deletes the policy intance of the Update Sales Return policy for the Sales Representitive role.

Cc508630.LegacyEndpoint(en-us,MSDN.10).gif** 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;
            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");

            // Create the role key for the role
            roleKey = new RoleKey();
            roleKey.Id = "aaeb72e0-77f9-4925-ab9a-73012417fb37";

            // Delete the policy instance for sales returns
            wsDynamicsGP.DeletePolicy(policyKey, roleKey, context);
        }
    }
}

Cc508630.NativeEndpoint(en-us,MSDN.10).gif** 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;
            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");

            // Create the role key for the role
            roleKey = new RoleKey();
            roleKey.Id = "aaeb72e0-77f9-4925-ab9a-73012417fb37";

            // Delete the policy instance for sales returns
            wsDynamicsGP.DeletePolicy(policyKey, roleKey, context);

            // Close the service
            if(wsDynamicsGP.State != CommunicationState.Faulted)
            {
                wsDynamicsGP.Close();
            }
        }
    }
}