GetEmployeePayCodeByKey


Description

Retrieves an employee pay code object based on the key value supplied.

Parameters

Parameter

Type

Description

key

EmployeePayCodeKey

The employee pay code key object that specifies the employee pay code to retrieve.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetEmployeePayCodeByKeyResult

EmployeePayCode

An employee pay code object.


Interfaces

 

Examples

The following C# example retrieves the employee pay code object with the employee Id value “ACKE0001” and the pay code value “COMM”. The employee pay code information 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;
			EmployeePayCode employeePayCode;
			EmployeePayCodeKey employeePayCodeKey;
			EmployeeKey employeeKey;
			PayCodeKey payCodeKey;

			// 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 an employee key
			employeeKey = new EmployeeKey();
			employeeKey.Id = "ACKE0001";

			// Create a pay code key
			payCodeKey = new PayCodeKey();
			payCodeKey.Id = "COMM";

			// Create an employee pay code key
			employeePayCodeKey = new EmployeePayCodeKey();
			employeePayCodeKey.EmployeeKey = employeeKey;
			employeePayCodeKey.PayCodeKey = payCodeKey;

			// Get the employee pay code object
			employeePayCode = wsDynamicsGP.GetEmployeePayCodeByKey(employeePayCodeKey, context);

			// Display the pay code for the employee
			MessageBox.Show("Employee: " + employeePayCode.EmployeePayCodeKey.EmployeeKey.Id 
				+ "   Pay code: " + employeePayCode.EmployeePayCodeKey.PayCodeKey.Id);
	}
}
}

 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;
			EmployeePayCode employeePayCode;
			EmployeePayCodeKey employeePayCodeKey;
			EmployeeKey employeeKey;
			PayCodeKey payCodeKey;

			// 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 an employee key
			employeeKey = new EmployeeKey();
			employeeKey.Id = "ACKE0001";

			// Create a pay code key
			payCodeKey = new PayCodeKey();
			payCodeKey.Id = "COMM";

			// Create an employee pay code key
			employeePayCodeKey = new EmployeePayCodeKey();
			employeePayCodeKey.EmployeeKey = employeeKey;
			employeePayCodeKey.PayCodeKey = payCodeKey;

			// Get the employee pay code object
			employeePayCode = wsDynamicsGP.GetEmployeePayCodeByKey(employeePayCodeKey, context);

			// Display the pay code for the employee
			MessageBox.Show("Employee: " + employeePayCode.EmployeePayCodeKey.EmployeeKey.Id 
				+ "   Pay code: " + employeePayCode.EmployeePayCodeKey.PayCodeKey.Id);

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


Documentation Feedback