Microsoft Dynamics AX Support

This blog contains posts by the Microsoft Dynamics AX Support teams Worldwide

Calling the LedgerGeneralJournal Service in AX 2012

Calling the LedgerGeneralJournal Service in AX 2012

Rate This
  • Comments 28

Below is an example of how to call the create operation on the GeneralJournalService in AX 2012.  My apologies for the way the code below is formatted!  This editor is clearly not made for code snippets.

GeneralJournalServiceClient client = new GeneralJournalServiceClient();

CallContext context = new CallContext();

context.Company =  "ceu";


AxdLedgerGeneralJournal journal = new AxdLedgerGeneralJournal();

AxdEntity_LedgerJournalTable journalHeader = new AxdEntity_LedgerJournalTable();

journalHeader.JournalName = "GenJrn";

AxdEntity_LedgerJournalTrans journalLine = new AxdEntity_LedgerJournalTrans();

journalLine.AccountType = AxdEnum_LedgerJournalACType.Ledger;

journalLine.AccountTypeSpecified = true;

journalLine.Company = "ceu";

AxdType_MultiTypeAccount account = new AxdType_MultiTypeAccount();

account.Account = "131100";

account.DisplayValue = "131100-OU_2311-OU_3569-Customer visit";

AxdType_DimensionAttributeValue dimValue1 = new AxdType_DimensionAttributeValue();

dimValue1.Name = "Department";

dimValue1.Value = "OU_2311";

AxdType_DimensionAttributeValue dimValue2 = new AxdType_DimensionAttributeValue();

dimValue2.Name = "CostCenter";

dimValue2.Value = "OU_3569";

AxdType_DimensionAttributeValue dimValue3 = new AxdType_DimensionAttributeValue();

dimValue3.Name = "ExpensePurpose";

dimValue3.Value = "Customer visit";

account.Values = new AxdType_DimensionAttributeValue[3] { dimValue1, dimValue2, dimValue3 };

journalLine.LedgerDimension = account;

journalLine.AmountCurDebit = 120;

journalLine.AmountCurDebitSpecified = true;

journalHeader.LedgerJournalTrans = new AxdEntity_LedgerJournalTrans[1] { journalLine };

journal.LedgerJournalTable = new AxdEntity_LedgerJournalTable[1] { journalHeader };



                client.create(context, journal);


catch (Exception e)


            string error = e.Message;


Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post
  • Can you do one in x++ also please.

  • Hi A,

    Check out this post:

    I have explained the difficult portions of creating general journal entries which are the financial dimensions using X++.

  • Hi Becky,

    do you installed cumulative update 2?

    I have a problem with the read and find operation for this service.

    Every time, i call the servie, i get the following error:

    Stack trace: Field 'recVersion' in table 'LedgerJournalTrans' has not been explicitly selected.

    if i add the field recversion to datasource InventJournalTable and InventJournalTrans of query AxdLedgerGeneralJournal, everything works fine.

    I believe, without cumulative update 2, it works without adding these fields.

    The error occurs inside a dll, so i cant debug this problem, but

    I dont understand, why ax needs this fields for a read/find method.

    In other services the field recversion exists in the datasources...

    Do you have the same problem?

    Best Regards,


  • Hi Luetter,

    I am not having problems calling the service on CU2.  I tested it to make sure,it is looking ok for me.  I did not have to modify the service to get it to work.


  • Hi Becky,

    thanks for your reply. Do call the read and find method, too?


  • Hi Mathias,

    Yes with the code below I can call the find method on CU2 without issue:

    static AxdLedgerGeneralJournal FindOrder()


               string generalJournal = "000426_010";

               AxdLedgerGeneralJournal foundgeneralJournal = null;

               CallContext context = new CallContext();

               context.Company = "ceu";

               //Instantiate an instance of the service client class

               GeneralJournalServiceClient proxy = new GeneralJournalServiceClient();



                   foundgeneralJournal = proxy.find(context, Program.createQueryCriteria(generalJournal));

                   Console.WriteLine("The journal was found.");


               catch (Exception e)


                   Console.WriteLine("The journal was not found.");


               return foundgeneralJournal;


           private static QueryCriteria createQueryCriteria(string journalValue)


               CriteriaElement[] criteriaElements = new CriteriaElement[1];

               criteriaElements[0] = new CriteriaElement();

               criteriaElements[0].DataSourceName = "LedgerJournalTable";

               criteriaElements[0].FieldName = "JournalNum";

               criteriaElements[0].Value1 = journalValue;

               QueryCriteria queryCriteria = new QueryCriteria();

               queryCriteria.CriteriaElement = criteriaElements;

               return queryCriteria;


  • Hi

    Is it possible to call LedgerGeneralService for fixed asset transaction and how?  

  • Hi Manon,

    I haven't tried creating fixed asset transactions via the general journal but I would think that you could do this since you can set the LedgerJournalActType enum to FixedAssets.

  • Becky,  

    Can i overwrite the exchange rate for different currencies in the aif service?  And how would I accomplish that.?

  • Hi Andy,

    There is a LedgerExchangeRateService that ships with AX.  It will let you create new exchange rates and retrieving existing ones.  The service does not contain an update operation and I don't think it should you need to keep the history of what your exchange rates were previously.

  • Hi Becky,

    in the service, can I fill in DefaultDimension for LedgerJournalTable? which is no Main Account, only dimensions combination.


  • The DefaultDimension field on the LedgerJournalTable is not exposed in the service because it is not included in the AxdLedgerGeneralJournal query. You would have to modify the query to include this field and then run the service update wizard.  Once the service includes the field then you should be able to set it.

  • Hi Becky,

    Please let me know How to write same LedgerDimension & OffsetDefaultDimension in an Inbound xml file.

    Thanks in advance..

  • Hi Mukesh,

    Have a look at this tool:

    It will generate sample xml files for you so you can see how to set values in the files you are sending in.

  • Hi Becky,

    I have tried this tool but it always gives an error as "No DNS entries exist for host aos_service_host". If possible then please mail me the sample xml for AxdLedgerGeneralJournal.

    Also, as you told above that if we need to include some more fields in the LedgerGeneralJournalService then we can modify AxdLedgerGeneralJournal query and include the extra fields and then we have to run update service wizard. I have did the same though new fields are not showing up in the schema, even I have done Incremental IL. Please guide.


Page 1 of 2 (28 items) 12