Friday, February 26, 2021

Send selected records from Temp Form Datasource to Class

 Recently, I had the need to send selected records of Form datasource that is a Temp table. 

The initial searches led me to the MultiSelectionHelper class with code something like this in my class:

MultiSelectionHelper helper = MultiSelectionHelper::construct();
helper.parmDataSource(_args.record().dataSource());

myTempTable = helper.getFirst();

while (myTempTable.RecId != 0)
{
    ... [LOGIC] ...
    myTempTable = helper.getNext();
}

This did NOT work at all.  I tried every type of table; Temp, InMemory, Regular.  I could not get MultiSelectionHelper to work.

So, I ended up using FormDataSource:

FormDataSource fds;
fds = _args.record().dataSource();

myTempTable = fds.getFirst(true);

while (myTempTable.RecId != 0)
{
    ... [LOGIC] ...
    myTempTable = fds.getNext();
}

Very similar code.  Just be sure to put 'true' in your call to 'getFirst' on the FDS object as that will ONLY retrieve marked / selected records.

Friday, February 5, 2021

General Ledger - Foreign Currency Revaluation

 Recently, I was brought into a conversation with my customer about their Foreign Currency Revaluation process.  

They felt that the standard process in AX wasn't doing it correctly based on their manual calculations so I did some research and debugging to figure out that basics of how this works.

Here is our sample parameters:


This is run in an entity that uses GBP as it's accounting currency.  Our parameters would suggest that we want to revalue transactions in Jan. of 2021.  However, due to my account being an 'Asset' account, the system changes my 'From' date to the beginning of my fiscal year. (In this case 11/1/2020) 
This causes the revaluation to be run for the entire year each time I run it, instead of just for the month I have specified.

I would be interested to know if this is standard accounting practice or if this is a bug in the system. 

As an FYI, the system will revalue the transactions using an exchange rate from the 'To' date specified in the parameter form.