Share via


CreateGLUnitAccount

Description

This method creates a new GL unit account.

Parameters

Parameter

Type

Description

unitAccount

GLUnitAccount

The GL unit 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

  • Dynamics GP
  • Financials

Examples

The following C# example creates a GL unit account with the key value "000-9045-00". The Key and Description properties are set. All other properties are left as default values.

Cc508430.LegacyEndpoint(en-us,MSDN.10).gif** 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;
            GLUnitAccount unitAccount;
            Policy unitAccountCreatePolicy;

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

            // Create a GL unit account object
            unitAccount = new GLUnitAccount();
            unitAccount.Key = accountNumberKey;
            unitAccount.Description = "Number of Workstations";

            // Get the create policy for unit accounts
            unitAccountCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateGLUnitAccount", context);

            // Create the unit account
            wsDynamicsGP.CreateGLUnitAccount(unitAccount, context, unitAccountCreatePolicy);
        }
    }
}

Cc508430.NativeEndpoint(en-us,MSDN.10).gif** Native endpoint **

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            GLAccountNumberKey accountNumberKey;
            GLUnitAccount unitAccount;
            Policy unitAccountCreatePolicy;

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

            // Create a GL unit account object
            unitAccount = new GLUnitAccount();
            unitAccount.Key = accountNumberKey;
            unitAccount.Description = "Number of Workstations";

            // Get the create policy for unit accounts
            unitAccountCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateGLUnitAccount", context);

            // Create the unit account
            wsDynamicsGP.CreateGLUnitAccount(unitAccount, context, unitAccountCreatePolicy);

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