Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Description
Retrieves a single employee object based on the key value supplied. The value returned by this method can be affected by entity ID filtering.
Parameters
Parameter |
Type |
Description |
|---|---|---|
key |
The employee key object that specifies the employee to retrieve. |
|
context |
Specifies information about how the method will be called. |
Return Value:
Value |
Type |
Description |
|---|---|---|
GetEmployeeByKeyResult |
An employee object. |
Interfaces
- Dynamics GP
- Human Resources/Payroll
Examples
The following C# example retrieves the employee with the key value "ACKE0001". The name information for the employee 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;
Employee employee;
EmployeeKey employeeKey;
Name name;
// 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";
// Retrieve the employee object
employee = wsDynamicsGP.GetEmployeeByKey(employeeKey, context);
// Retrieve the employee name information
name = new Name();
name = employee.Name;
// Display the name information
MessageBox.Show(name.Given + " " + name.Middle + " " + name.Family);
}
}
}
** Native endpoint **
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;
namespace DynamicsGPWebServiceSample
{
class Program
{
static void Main(string[] args)
{
CompanyKey companyKey;
Context context;
Employee employee;
EmployeeKey employeeKey;
Name name;
// 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";
// Retrieve the employee object
employee = wsDynamicsGP.GetEmployeeByKey(employeeKey, context);
// Retrieve the employee name information
name = new Name();
name = employee.Name;
// Display the name information
MessageBox.Show(name.Given + " " + name.Middle + " " + name.Family);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}