CreateGLFixedAllocationAccount


Description

This method creates a new GL fixed allocation account.

Parameters

Parameter

Type

Description

fixedAllocationAccount

GLFixedAllocationAccount

The GL fixed 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 fixed allocation account with the key value “000-6170-00”. The fixed allocation account identifies the posting accounts “000-6170-04” and “000-6170-05” as distribution accounts. Each distribution account receives a 50% allocation. 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;
			GLAccountNumberKey staffAccount;
			GLAccountNumberKey lineAccount;
			GLFixedAllocationAccount glFixedAllocationAccount;
			GLAllocationDistributionAccountKey staffDistributionAccountKey;
			GLAllocationDistributionAccountKey lineDistributionAccountKey;
			GLFixedAllocationDistributionAccount staffDistributionAccount;
			GLFixedAllocationDistributionAccount lineDistributionAccount;
			Percent allocationPercentage;
			Policy fixedAllocationAccountCreatePolicy;

			// 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 fixed allocation account
			accountNumberKey = new GLAccountNumberKey();
			accountNumberKey.Id = "000-6170-00";

			// Create the allocation percentage object
			allocationPercentage = new Percent();
			allocationPercentage.Value = .50m;

			// Create a distribution account object:
			// Create an account number key to specify the staff distribution account
			staffAccount = new GLAccountNumberKey();
			staffAccount.Id = "000-6170-04";

			// Create a distribution account key
			staffDistributionAccountKey = new GLAllocationDistributionAccountKey();
			staffDistributionAccountKey.AccountKey = accountNumberKey;
			staffDistributionAccountKey.DistributionAccountKey = staffAccount;

			// Create the distribution account object
			staffDistributionAccount = new GLFixedAllocationDistributionAccount();
			staffDistributionAccount.Key = staffDistributionAccountKey;
			staffDistributionAccount.Percentage = allocationPercentage;

			// Create a second distribution account object:
			// Create an account number key to specify the line distribution account
			lineAccount = new GLAccountNumberKey();
			lineAccount.Id = "000-6170-05";

			// Create a distribution account key
			lineDistributionAccountKey = new GLAllocationDistributionAccountKey();
			lineDistributionAccountKey.AccountKey = accountNumberKey;
			lineDistributionAccountKey.DistributionAccountKey = lineAccount;

			// Create the distribution account object
			lineDistributionAccount = new GLFixedAllocationDistributionAccount();
			lineDistributionAccount.Key = lineDistributionAccountKey;
			lineDistributionAccount.Percentage = allocationPercentage;

			// Add both distribution account objects to an array of GL fixed 
			// allocation distribution account objects
			GLFixedAllocationDistributionAccount[] distributionAccounts = 
			{ staffDistributionAccount, lineDistributionAccount };

			// Create a fixed allocation account object
			glFixedAllocationAccount = new GLFixedAllocationAccount();
			glFixedAllocationAccount.Key = accountNumberKey;
			glFixedAllocationAccount.Description = "Janitorial Services";
			glFixedAllocationAccount.Distributions = distributionAccounts;

			// Get the create policy for a GL fixed allocation account
			fixedAllocationAccountCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateGLFixedAllocationAccount", context);

			// Create the GL fixed allocation account
			wsDynamicsGP.CreateGLFixedAllocationAccount(glFixedAllocationAccount, 
			context, fixedAllocationAccountCreatePolicy);
	}
}
}

 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;
			GLAccountNumberKey staffAccount;
			GLAccountNumberKey lineAccount;
			GLFixedAllocationAccount glFixedAllocationAccount;
			GLAllocationDistributionAccountKey staffDistributionAccountKey;
			GLAllocationDistributionAccountKey lineDistributionAccountKey;
			GLFixedAllocationDistributionAccount staffDistributionAccount;
			GLFixedAllocationDistributionAccount lineDistributionAccount;
			Percent allocationPercentage;
			Policy fixedAllocationAccountCreatePolicy;

			// 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 fixed allocation account
			accountNumberKey = new GLAccountNumberKey();
			accountNumberKey.Id = "000-6170-00";

			// Create the allocation percentage object
			allocationPercentage = new Percent();
			allocationPercentage.Value = .50m;

			// Create a distribution account object:
			// Create an account number key to specify the staff distribution account
			staffAccount = new GLAccountNumberKey();
			staffAccount.Id = "000-6170-04";

			// Create a distribution account key
			staffDistributionAccountKey = new GLAllocationDistributionAccountKey();
			staffDistributionAccountKey.AccountKey = accountNumberKey;
			staffDistributionAccountKey.DistributionAccountKey = staffAccount;

			// Create the distribution account object
			staffDistributionAccount = new GLFixedAllocationDistributionAccount();
			staffDistributionAccount.Key = staffDistributionAccountKey;
			staffDistributionAccount.Percentage = allocationPercentage;

			// Create a second distribution account object:
			// Create an account number key to specify the line distribution account
			lineAccount = new GLAccountNumberKey();
			lineAccount.Id = "000-6170-05";

			// Create a distribution account key
			lineDistributionAccountKey = new GLAllocationDistributionAccountKey();
			lineDistributionAccountKey.AccountKey = accountNumberKey;
			lineDistributionAccountKey.DistributionAccountKey = lineAccount;

			// Create the distribution account object
			lineDistributionAccount = new GLFixedAllocationDistributionAccount();
			lineDistributionAccount.Key = lineDistributionAccountKey;
			lineDistributionAccount.Percentage = allocationPercentage;

			// Add both distribution account objects to an array of GL fixed 
			// allocation distribution account objects
			GLFixedAllocationDistributionAccount[] distributionAccounts = 
			{ staffDistributionAccount, lineDistributionAccount };

			// Create a fixed allocation account object
			glFixedAllocationAccount = new GLFixedAllocationAccount();
			glFixedAllocationAccount.Key = accountNumberKey;
			glFixedAllocationAccount.Description = "Janitorial Services";
			glFixedAllocationAccount.Distributions = distributionAccounts;

			// Get the create policy for a GL fixed allocation account
			fixedAllocationAccountCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateGLFixedAllocationAccount", context);

			// Create the GL fixed allocation account
			wsDynamicsGP.CreateGLFixedAllocationAccount(glFixedAllocationAccount, 
			context, fixedAllocationAccountCreatePolicy);

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


Documentation Feedback