Search code examples
axaptadynamics-ax-2012

how to insert a string value from an XML to the offset account segmented textbox in AX?


I am trying to insert values into the segmented text box of the Offset Account Type

enter image description here
I will be placing strings, I would be placing only values for Main Account, and Cost Center and the rest would be Not Applicable (zeros)

offsetcon = [lineItemsNode.selectSingleNode("GLAccount").text(), "00","00",lineItemsNode.selectSingleNode("CostCenter").text(),"0000","000","000","00000","000","00"];
            trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetcon));

I have tried the code above and I get the error that

Main Acount 00 does not exist

from what I know is that Main Account is the first index in the container, and the error says its not.


Solution

  • according to what I've found out...

    The offset account has a segmented value, if you're going to pass a string/text to it, it must be placed in a container.

    offsetContainer =[ MainAccount, MainAccount, *Number of Dimensions*, *Name of the Dimension*, *Value of the Dimension*, ... ]; 
    

    ... - means more can be added. Disregard the asterisks ().*

    The first two segments are the MainAccount (I am really not sure on the first segment, please correct me if I am wrong. But I've researched about it and it has a different value than the second, in my case I used the same value as the second segment and it worked for me.), then the next is the Number of Dimensions. This is the number of segments that you're going to place a value after the MainAccountId, then the Name of the Dimensions is name of the segment. Lastly, the Value of the Dimension this is the value you're going to assign to the dimension you just named.

    So here's an example of a segment.

    Here's an example of a segment

    and here is how you will code the container:

    offsetContainer = [ 1101006, 
                        1101006, 
                        5, 
                        'BudORProject',
                        '00',
                        'Local_OverSeas',
                        '00',
                        'ProfitCenter',
                        '0000',
                        'Hub',
                        '000' 
                                ];
    

    So since there are 5 more segments after the MainAccount, 5 is the value for the Number of Dimensions. *

    Now using it on your code:

    AxLedgerJournalTrans    trans   = new AxLedgerJournalTrans();
    trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetcon));
    

    Don't forget to use AxdDimensionUtil::getLedgerAccountId method where you will place the container, as seen above.