This method associates a specified pay code with a specified employee.
Parameter |
Type |
Description |
---|---|---|
employeePayCode |
The employee pay code object being created. |
|
context |
Specifies information about how the method will be called. |
|
policy |
Specifies the set of behaviors and behavior options to be applied during the operation. |
The following C# example associates the pay code “COMM” with the employee that has the the ID “ACKE0001”. The remaining properties use default values. The CreateEmployeePayCode operation associates the pay code with the employee.
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; EmployeePayCode employeePayCode; EmployeePayCodeKey employeePayCodeKey; EmployeeKey employeeKey; PayCodeKey payCodeKey; Policy employeePayCodeCreatePolicy; // 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; // Create an employee pay code object employeePayCode = new EmployeePayCode(); employeePayCode.EmployeePayCodeKey = employeePayCodeKey; // Get the create policy for employee pay code objects employeePayCodeCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateEmployeePayCode", context); // Create the employee pay code object wsDynamicsGP.CreateEmployeePayCode(employeePayCode, context, employeePayCodeCreatePolicy); } } }
Native endpoint
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; EmployeePayCode employeePayCode; EmployeePayCodeKey employeePayCodeKey; EmployeeKey employeeKey; PayCodeKey payCodeKey; Policy employeePayCodeCreatePolicy; // 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; // Create an employee pay code object employeePayCode = new EmployeePayCode(); employeePayCode.EmployeePayCodeKey = employeePayCodeKey; // Get the create policy for employee pay code objects employeePayCodeCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateEmployeePayCode", context); // Create the employee pay code object wsDynamicsGP.CreateEmployeePayCode(employeePayCode, context, employeePayCodeCreatePolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }