GetPolicyListByRoleKey


Description

Retrieves the list of policy summary objects for policies that have a policy instance for the specified role.

Parameters

Parameter

Type

Description

roleKey

RoleKey

The role key object that specifies which policy instances will be included in the list.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetPolicyListByRoleKeyResult

ArrayOfPolicySummary

The list of policy summary objects for the policy instances defined for the specified role.


Interfaces

 

Examples

The following C# example retrieves the list of policy summary object for the policy instances defined for the “Sales Representitive” role defined in the Dynamics Security Service. The GUID that corresponds to this role is used to create the role key object used for this method. The total number of policy instances is displayed in a message box. The names of the policies are also displayed.

 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;
			PolicySummary[] policySummaryList;
			RoleKey roleKey;

			// Create an instance of the service
			DynamicsGP wsDynamicsGP = new DynamicsGP();

			// Be sure that default credentials are being 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
			context.OrganizationKey = (OrganizationKey)companyKey;

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

			// Retrieve the list of policy instances for this role
			policySummaryList = wsDynamicsGP.GetPolicyListByRoleKey(roleKey, context);

			// Display the number of policy summary objects
			MessageBox.Show("Total policies for this role: " + policySummaryList.Length.ToString());

			foreach (PolicySummary p in policySummaryList)
			{
				MessageBox.Show(p.Name);
		}
	}
}
}

 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;
			PolicySummary[] policySummaryList;
			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
			context.OrganizationKey = (OrganizationKey)companyKey;

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

			// Retrieve the list of policy instances for this role
			policySummaryList = wsDynamicsGP.GetPolicyListByRoleKey(roleKey, context);

			// Display the number of policy summary objects
			MessageBox.Show("Total policies for this role: " + policySummaryList.Length.ToString());

			foreach (PolicySummary p in policySummaryList)
			{
				MessageBox.Show(p.Name);
		}

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


Documentation Feedback