RE: DimensionDynamicAccount
Hi Morten,
There are basically two ways to change a dimension value, you can either change it by the dimension name or you can merge it with another dimension.
The sample code I shared has the dimension name hardcoded for demonstration purposes, so you would need to change that to the name of you dimension.
But it's not good to have it hardcoded, so you would need to create a parameter where the user could determine which one is the site dimension. Then you get the dimension name from this parameter.
The other option is the way the LedgerJournalTrans table works, for example, it can initialize the financial dimension values from the customer account, merging the default dimension configured on the customer master with the current dimensions on the journal line (which will normally be empty at this time).
The journal line does the same with the journal header, the journal header dimensions come from the journal name and when you add a new line the line is initialized with the header dimensions.
If you have a customer, vendor, journal header or any other master entity that already has a default dimension, you can use it to initialize your field, this way you wouldn't need a new parameter to set the dimension name.
Here is a sample code on how to merge a default dimension with an existing ledger dimension:
DimensionDefaultingService::serviceCreateLedgerDimension(ledgerDimension, defaultDimension);
You could use this to get the site dimension from a customer, for example.