Dynamics AX 365 Create Main Account Using X++


DimensionServiceProvider class manages business logic for account. Following is the sample code how to create account using x++.

  DimensionServiceProvider   dimensionServiceProvider;   
  MainAccountContract     mainAccountContract;   
  MainAccountCategory     mainAccountCategory;   
  DimensionLedgerAccountType  dimensionLedgerAccountType;   
  ;   
   
  ttsbegin;  
    
  select firstonly mainAccountCategory where mainAccountCategory.AccountCategory == "CASH";   
  mainAccountContract = new MainAccountContract();   
  mainAccountContract.parmName("MyDemoAccount");   
  mainAccountContract.parmMainAccountId("0000001");   
  mainAccountContract.parmIsBlockedforManualEntry(NoYes::No);   
  mainAccountContract.parmType(str2Enum(dimensionLedgerAccountType, "Balance sheet"));    
  mainAccountContract.parmAccountCategoryRef(mainAccountCategory.AccountCategoryRef);   
  mainAccountContract.parmLedgerChartOfAccounts("MyDemoLedgerChartOfAccount");   
  dimensionServiceProvider = new DimensionServiceProvider();   
  dimensionServiceProvider.createMainAccount(mainAccountContract);   
    
  ttscommit;   

Comments

  1. hi,.. can i publish this post in my blog?

    ReplyDelete
  2. hi, Raza.
    is this DimensionServiceProvider.CreateMainAccount() only for create a new one?.. how about to update a mainaccount? ..can we use this class?

    ReplyDelete

Post a Comment

Popular posts from this blog

X++ Get Start Date and End Date of Month

Dynamics AX 365 : The name does not denote a class, a table or an extended data type

Error while setting server report parameters. Error message: The permissions granted to user are insufficient for performing this operation. (rsAccessDenied)