Hi Folks,
Intercompany (also known as cross company) journal imports are a common requirement in multi company environments, but there are no standard data entity to support this. However LedgerJournalTrans table have fields for Company or OffsetCompany but these are not exposed to LedgerJournalEntity.
Fortunately, D365FO’s extensibility model allows us to extend both the entity and the underlying data model cleanly, with minimum development.
First lets understand what all I need to achieve this,
1. LedgerJournalEntity entity Extension
2. LedgerJournalEntityStaging table extension
3. Extension class for LedgerJournalEntity
Step 1: Extend LedgerJournalEntity and copy 'Company' and 'OffsetCompany' from entity datasource table (LedgerJournalTrans) and add them in entity field node.
Step 2: Extend LedgerJournalEntityStaging table and add both fields in this table (you can copy fields from LedgerJournalTrans table).
Step 3: Create an extension class for LedgerJournalEntity and extend 'CopyCustomStagingToTarget' method, and add below code,
<Gist code above>
build and synch your solution and you are all set to import intercompany journals.
Hope this helps.
Thanks,
-Harry
Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta