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 corporate account object based on the key value supplied.
Parameters
Parameter |
Type |
Description |
|---|---|---|
key |
A customer key object that specifies the corporate account object to retrieve. |
|
context |
Specifies information about how the method will be called. |
Return Value:
Value |
Type |
Description |
|---|---|---|
GetCorporateAccountByKeyResult |
A corporate account object. |
Interfaces
- Dynamics GP
- Sales
Examples
The following C# example retrieves the corporate account with the key value "COMMUNIC0001". The corporate account's total number of members is displayed in a message box. The "COMMUNIC0001" corporate account used in this example was created by the CreateCorporateAccount example.
** 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;
CorporateAccount corporateAccount;
CustomerKey customerKey;
// Create an instance of the service
DynamicsGP wsDynamicsGP = new DynamicsGP();
// Be sure the 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;
// Create a customer key specifying the corporate account
customerKey = new CustomerKey();
customerKey.Id = "COMMUNIC0001";
// Retrieve the corporate account object
corporateAccount = wsDynamicsGP.GetCorporateAccountByKey(customerKey, context);
// Display the number of members for the corporate account
MessageBox.Show("Total number of members: " + corporateAccount.Members.Length.ToString());
}
}
}
** 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;
CorporateAccount corporateAccount;
CustomerKey customerKey;
// 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;
// Create a customer key specifying the corporate account
customerKey = new CustomerKey();
customerKey.Id = "COMMUNIC0001";
// Retrieve the corporate account object
corporateAccount = wsDynamicsGP.GetCorporateAccountByKey(customerKey, context);
// Display the number of members for the corporate account
MessageBox.Show("Total number of members: " + corporateAccount.Members.Length.ToString());
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}