CreateGLVariableAllocationAccount


Description

This method creates a new GL variable allocation account.

Parameters

Parameter

Type

Description

variableAllocationAccount

GLVariableAllocationAccount

The GL variable allocation account being created.

context

Context

Specifies information about how the method will be called.

policy

Policy

Specifies the set of behaviors and behavior options to be applied during the operation.


Interfaces

 

Examples

The following C# example creates a GL variable allocation account with the key value “000-6510-00”. The variable allocation account identifies the posting accounts “300-6510-00” and “400-6510-00” as distribution accounts. Each distribution account specifies the breakdown account used to determine the variable allocation amount. The Description property is set and all other properties are left as default values.

 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;
			GLAccountNumberKey accountNumberKey;
			GLVariableAllocationAccount variableAllocationAccount;
			GLVariableAllocationDistributionAccount salesDistributionAccount;
			GLVariableAllocationDistributionAccount serviceDistributionAccount;
			GLAccountNumberKey salesTelephoneExpenseAccount;
			GLAccountNumberKey serviceTelephoneExpenseAccount;
			GLAllocationDistributionAccountKey salesDistributionAccountKey;
			GLAllocationDistributionAccountKey serviceDistributionAccountKey;
			Policy variableAllocationAccountCreatePolicy;

			// 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 GL number key object to identify the new GL variable allocation account
			accountNumberKey = new GLAccountNumberKey();
			accountNumberKey.Id = "000-6510-00";


			// Create the sales distribution account object:
			// Create a GL number key object to specify the distribution account
			salesTelephoneExpenseAccount = new GLAccountNumberKey();
			salesTelephoneExpenseAccount.Id = "300-6510-00";

			// Create a GL allocation distribution account key
			salesDistributionAccountKey = new GLAllocationDistributionAccountKey();
			salesDistributionAccountKey.AccountKey = accountNumberKey;
			salesDistributionAccountKey.DistributionAccountKey = salesTelephoneExpenseAccount;

			// Create the breakdown account for the sales distribution account
			GLAllocationDistributionAccountKey salesAllocationDistributionAccountKey = 
			new GLAllocationDistributionAccountKey();
			salesAllocationDistributionAccountKey.AccountKey = salesDistributionAccountKey.AccountKey;
			salesAllocationDistributionAccountKey.DistributionAccountKey =
			salesDistributionAccountKey.DistributionAccountKey;

			// Create a GL account number key to specify the breakdown account
			GLAccountNumberKey salesAllocationAccountKey = new GLAccountNumberKey();
			salesAllocationAccountKey.Id = "300-9020-00";

			// Create a breakdown account key and specify the distribution account
			GLVariableAllocationBreakdownAccountKey salesBreakdownAccountKey = 
			new GLVariableAllocationBreakdownAccountKey();
			salesBreakdownAccountKey.BreakdownAccountKey = salesAllocationAccountKey;
			salesBreakdownAccountKey.AllocationDistributionAccountKey =
			salesAllocationDistributionAccountKey;

			// Create a GL variable allocation breakdown account object
			GLVariableAllocationBreakdownAccount salesBreakdownAccount = 
			new GLVariableAllocationBreakdownAccount();
			salesBreakdownAccount.Key = salesBreakdownAccountKey;

			// Add the breakdown account to the array
			GLVariableAllocationBreakdownAccount[] salesBreakdownAccounts = { salesBreakdownAccount };

			// Create the sales distribution account
			salesDistributionAccount = new GLVariableAllocationDistributionAccount();
			salesDistributionAccount.Key = salesDistributionAccountKey;
			salesDistributionAccount.Breakdowns = salesBreakdownAccounts;


			// Create a service distribution account object:
			// Create a GL account number key to specify the distribution account
			serviceTelephoneExpenseAccount = new GLAccountNumberKey();
			serviceTelephoneExpenseAccount.Id = "400-6510-00";

			// Create a GL allocation distribution account key
			serviceDistributionAccountKey = new GLAllocationDistributionAccountKey();
			serviceDistributionAccountKey.AccountKey = accountNumberKey;
			serviceDistributionAccountKey.DistributionAccountKey = serviceTelephoneExpenseAccount;

			// Create the breakdown account for the service distribution account
			GLAllocationDistributionAccountKey serviceAllocationDistributionAccountKey = 
			new GLAllocationDistributionAccountKey();
			serviceAllocationDistributionAccountKey.AccountKey = serviceDistributionAccountKey.AccountKey;
			serviceAllocationDistributionAccountKey.DistributionAccountKey =
			serviceDistributionAccountKey.DistributionAccountKey;

			// Create a GL account number key to specify the breakdown account
			GLAccountNumberKey serviceAllocationAccountKey = new GLAccountNumberKey();
			serviceAllocationAccountKey.Id = "400-9020-00";

			// Create a breakdown account key and specify the distribution account
			GLVariableAllocationBreakdownAccountKey serviceBreakdownAccountKey = 
			new GLVariableAllocationBreakdownAccountKey();
			serviceBreakdownAccountKey.BreakdownAccountKey = serviceAllocationAccountKey;
			serviceBreakdownAccountKey.AllocationDistributionAccountKey =
			serviceAllocationDistributionAccountKey;

			// Create a GL variable allocation breakdown account object
			GLVariableAllocationBreakdownAccount serviceBreakdownAccount = 
			new GLVariableAllocationBreakdownAccount();
			serviceBreakdownAccount.Key = serviceBreakdownAccountKey;

			// Add the breakdown account to the array
			GLVariableAllocationBreakdownAccount[] serviceBreakdownAccounts = { serviceBreakdownAccount };

			// Create the service distribution account object
			serviceDistributionAccount = new GLVariableAllocationDistributionAccount();
			serviceDistributionAccount.Key = serviceDistributionAccountKey;
			serviceDistributionAccount.Breakdowns = serviceBreakdownAccounts;


			// Add the sales and service distribution account objects to an array
			// the array will be assigned to the Distributions property of the GL 
			// variable allocation account object
			GLVariableAllocationDistributionAccount[] distributionAccounts = 
			{ salesDistributionAccount, serviceDistributionAccount };


			// Create the GL variable allocation account object
			variableAllocationAccount = new GLVariableAllocationAccount();
			variableAllocationAccount.Key = accountNumberKey;
			variableAllocationAccount.Description = "Telephone Expense";
			variableAllocationAccount.Distributions = distributionAccounts;

			// Get the create policy for GL variable allocation accounts
			variableAllocationAccountCreatePolicy = wsDynamicsGP.GetPolicyByOperation
			("CreateGLVariableAllocationAccount", context);

			// Create the GL variable allocation account
			wsDynamicsGP.CreateGLVariableAllocationAccount(variableAllocationAccount, 
			context, variableAllocationAccountCreatePolicy);
	}
}
}

 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;
			GLAccountNumberKey accountNumberKey;
			GLVariableAllocationAccount variableAllocationAccount;
			GLVariableAllocationDistributionAccount salesDistributionAccount;
			GLVariableAllocationDistributionAccount serviceDistributionAccount;
			GLAccountNumberKey salesTelephoneExpenseAccount;
			GLAccountNumberKey serviceTelephoneExpenseAccount;
			GLAllocationDistributionAccountKey salesDistributionAccountKey;
			GLAllocationDistributionAccountKey serviceDistributionAccountKey;
			Policy variableAllocationAccountCreatePolicy;

			// 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 GL number key object to identify the new GL variable allocation account
			accountNumberKey = new GLAccountNumberKey();
			accountNumberKey.Id = "000-6510-00";


			// Create the sales distribution account object:
			// Create a GL number key object to specify the distribution account
			salesTelephoneExpenseAccount = new GLAccountNumberKey();
			salesTelephoneExpenseAccount.Id = "300-6510-00";

			// Create a GL allocation distribution account key
			salesDistributionAccountKey = new GLAllocationDistributionAccountKey();
			salesDistributionAccountKey.AccountKey = accountNumberKey;
			salesDistributionAccountKey.DistributionAccountKey = salesTelephoneExpenseAccount;

			// Create the breakdown account for the sales distribution account
			GLAllocationDistributionAccountKey salesAllocationDistributionAccountKey = 
			new GLAllocationDistributionAccountKey();
			salesAllocationDistributionAccountKey.AccountKey = salesDistributionAccountKey.AccountKey;
			salesAllocationDistributionAccountKey.DistributionAccountKey =
			salesDistributionAccountKey.DistributionAccountKey;

			// Create a GL account number key to specify the breakdown account
			GLAccountNumberKey salesAllocationAccountKey = new GLAccountNumberKey();
			salesAllocationAccountKey.Id = "300-9020-00";

			// Create a breakdown account key and specify the distribution account
			GLVariableAllocationBreakdownAccountKey salesBreakdownAccountKey = 
			new GLVariableAllocationBreakdownAccountKey();
			salesBreakdownAccountKey.BreakdownAccountKey = salesAllocationAccountKey;
			salesBreakdownAccountKey.AllocationDistributionAccountKey =
			salesAllocationDistributionAccountKey;

			// Create a GL variable allocation breakdown account object
			GLVariableAllocationBreakdownAccount salesBreakdownAccount = 
			new GLVariableAllocationBreakdownAccount();
			salesBreakdownAccount.Key = salesBreakdownAccountKey;

			// Add the breakdown account to the array
			GLVariableAllocationBreakdownAccount[] salesBreakdownAccounts = { salesBreakdownAccount };

			// Create the sales distribution account
			salesDistributionAccount = new GLVariableAllocationDistributionAccount();
			salesDistributionAccount.Key = salesDistributionAccountKey;
			salesDistributionAccount.Breakdowns = salesBreakdownAccounts;


			// Create a service distribution account object:
			// Create a GL account number key to specify the distribution account
			serviceTelephoneExpenseAccount = new GLAccountNumberKey();
			serviceTelephoneExpenseAccount.Id = "400-6510-00";

			// Create a GL allocation distribution account key
			serviceDistributionAccountKey = new GLAllocationDistributionAccountKey();
			serviceDistributionAccountKey.AccountKey = accountNumberKey;
			serviceDistributionAccountKey.DistributionAccountKey = serviceTelephoneExpenseAccount;

			// Create the breakdown account for the service distribution account
			GLAllocationDistributionAccountKey serviceAllocationDistributionAccountKey = 
			new GLAllocationDistributionAccountKey();
			serviceAllocationDistributionAccountKey.AccountKey = serviceDistributionAccountKey.AccountKey;
			serviceAllocationDistributionAccountKey.DistributionAccountKey =
			serviceDistributionAccountKey.DistributionAccountKey;

			// Create a GL account number key to specify the breakdown account
			GLAccountNumberKey serviceAllocationAccountKey = new GLAccountNumberKey();
			serviceAllocationAccountKey.Id = "400-9020-00";

			// Create a breakdown account key and specify the distribution account
			GLVariableAllocationBreakdownAccountKey serviceBreakdownAccountKey = 
			new GLVariableAllocationBreakdownAccountKey();
			serviceBreakdownAccountKey.BreakdownAccountKey = serviceAllocationAccountKey;
			serviceBreakdownAccountKey.AllocationDistributionAccountKey =
			serviceAllocationDistributionAccountKey;

			// Create a GL variable allocation breakdown account object
			GLVariableAllocationBreakdownAccount serviceBreakdownAccount = 
			new GLVariableAllocationBreakdownAccount();
			serviceBreakdownAccount.Key = serviceBreakdownAccountKey;

			// Add the breakdown account to the array
			GLVariableAllocationBreakdownAccount[] serviceBreakdownAccounts = { serviceBreakdownAccount };

			// Create the service distribution account object
			serviceDistributionAccount = new GLVariableAllocationDistributionAccount();
			serviceDistributionAccount.Key = serviceDistributionAccountKey;
			serviceDistributionAccount.Breakdowns = serviceBreakdownAccounts;


			// Add the sales and service distribution account objects to an array
			// the array will be assigned to the Distributions property of the GL 
			// variable allocation account object
			GLVariableAllocationDistributionAccount[] distributionAccounts = 
			{ salesDistributionAccount, serviceDistributionAccount };


			// Create the GL variable allocation account object
			variableAllocationAccount = new GLVariableAllocationAccount();
			variableAllocationAccount.Key = accountNumberKey;
			variableAllocationAccount.Description = "Telephone Expense";
			variableAllocationAccount.Distributions = distributionAccounts;

			// Get the create policy for GL variable allocation accounts
			variableAllocationAccountCreatePolicy = wsDynamicsGP.GetPolicyByOperation
			("CreateGLVariableAllocationAccount", context);

			// Create the GL variable allocation account
			wsDynamicsGP.CreateGLVariableAllocationAccount(variableAllocationAccount, 
			context, variableAllocationAccountCreatePolicy);

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


Documentation Feedback