Cannot import data through custom fields in LedgerJournalEntity
Recently, I came across a requirement to add custom fields in LedgerJournalTrans for importing Customer Expenses through General Journal.
So, I have created extension of LedgerJournalTrans and added new fields and did the same in entity and staging table.
But out of my surprise, I cannot import the data through these new fields. I did model build, sync, regenerated mapping, refreshed entity. But nothing helped me. I can also see the data coming to staging but not to Entity or underlying tables. Then did the debug to see what actually is happening.
What’s the outcome?
On debug, I came to know that a method is written in this entity where actually the data from the staging is being copied to LedgerJournalEntity.
All the major functionality of this entity is found in this method, where I can see it copies the data from staging to target, validates the data etc. So first I tried doing COC on the methods which are found inside the present method which are responsible for insert and update of the data in LedgerJournalEntity. Only COC on update method worked but on create, COC did not work.
Then finally thought of doing a COC on complete method.
Then I did the post COC on copyCustomStagingToTarget() to achieve my requirement.
Below is the code which shows the COC on this method.
[ExtensionOf(tableStr(LedgerJournalEntity))] final class MYLedgerJournalEntity_Extension { public static container copyCustomStagingToTarget(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution) { container ret; ret = next copyCustomStagingToTarget(_dmfDefinitionGroupExecution); LedgerJournalTrans ledgerJournalTrans; LedgerJournalEntityStaging staging; ledgerJournalTrans.skipDataMethods(true); update_recordset ledgerJournalTrans setting MYField1 = staging.MYField1, MYField2 = staging.MYField2 join staging where staging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup && staging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId && staging.TransferStatus == DMFTransferStatus::Completed && staging.JournalBatchNumber == ledgerJournalTrans.JournalNum && staging.LineNumber == ledgerJournalTrans.LineNum; return ret; } }
In this way, to populate the data into custom fields, COC on this method should be made.
What’s the issue? Why I am not able to import?
The reason why I am not able to import the data is, that the Set based processing (set based SQL operations) flag has been switched on for LedgerJournalEntity. So, data cannot be imported by normal process like how we do for other entites. So custom code is required for this.
Happy Learning!
Comments
-
Hi Sathish For all standard data entities, normal way of extension like adding new fields in staging and entity and the related tables via extension is enough. But if that standard entity has set based processing enabled, then normal process doesn't work. We need to do the extension of the above said method via COC. And yes, this is for all entities having set based processing enabled.
-
Hello Bharani, This is only for LedgerJournalEntity or for the all the default entity if we extended has to write COC?
*This post is locked for comments