Hi Readers,
I hope you all are following this series and followed and completed what we have discussed till now. If you are new to this then Please Refer Table of Index.
We are about to finish this series with 2 more articles.
In this part of this extension as per customer, the requirement is had the Sales Header Source Code to be updated in Item Ledger Entries also.
As NAV Experts all my readers know how to transfer data from Sales Header to Item Ledger Entries that is -
1. Data from Sales Header move to Item Journal Line.
2. From item, Journal data move to Item Ledger Entries.
With that been said, we will require to have "Source of Sales" field in Item Journal Line and Item Ledger Entries.
Let's build two table extension to start with -
Add two new files with name as per our standard -
Next, I am sure that we all want to see the value to the user in Item Ledger Entry page, so let's add a page extension with the name - SDH_PageExt_50003_ItemLedgerEntriesExt.al, as shown below.
Now we need to identify a Published event that can do these two things -
As C/AL, experts we know where these events were supposed to be placed i.e. -
But Code is changing for a while and following are changes -
1. During Sales order posting in Codeunit 80, Item Journal line record is inserted using a function in Table 83 "Item Journal Line" - CopyFromSalesHeader where Microsoft has added an event "OnAfterCopyItemJnlLineFromSalesHeader" that can be Subscribe to transfer custom values as shown below.
2. Item Ledger Entries are inserted via Codeunit 22 using the function "InitItemLedgEntry". Microsoft has added an event "OnAfterInitItemLedgEntry" that we can Subscribe to Transfer Custom values as shown below.
Lot's of theory, Let's add those two subscribers and respective code in our subscriber Codeunit created in the last article.
1. Add new subscriber in the same Codeunit using snippet teventsub to get the skeleton of the subscriber as shown below.
Lets assign parameters -
Add all available parameters to Function / Procedure (as discussed in last article).
2. Add new subscriber in the same Codeunit using snippet teventsub to get skeleton of subscriber as shown below.
Lets assign parameters -
Add all available parameters to Function / Procedure (as discussed in last article).
The Newly added subscribers with the code will look like as below.
With this, the functionality that customer asked for is ready to be used. In Next article, we will test this functionality after Publishing modified extension.
Stay Tuned for more and please add comments if any questions/suggestions.
Regards,
Saurav Dhyani
www.sauravdhyani.com
I hope you all are following this series and followed and completed what we have discussed till now. If you are new to this then Please Refer Table of Index.
We are about to finish this series with 2 more articles.
In this part of this extension as per customer, the requirement is had the Sales Header Source Code to be updated in Item Ledger Entries also.
As NAV Experts all my readers know how to transfer data from Sales Header to Item Ledger Entries that is -
1. Data from Sales Header move to Item Journal Line.
2. From item, Journal data move to Item Ledger Entries.
With that been said, we will require to have "Source of Sales" field in Item Journal Line and Item Ledger Entries.
Let's build two table extension to start with -
Add two new files with name as per our standard -
- SDH_TableExt_50003_ItemJnlLineExt.al
- SDH_TableExt_50004_ItemLedgerExt.al
Next, I am sure that we all want to see the value to the user in Item Ledger Entry page, so let's add a page extension with the name - SDH_PageExt_50003_ItemLedgerEntriesExt.al, as shown below.
Now we need to identify a Published event that can do these two things -
- Transfer value of Source of Sales from Sales Header to Item Journal Line During Posting.
- Transfer value of Source of Sales from Item Journal line to Item Ledger Entry during Posting.
As C/AL, experts we know where these events were supposed to be placed i.e. -
- Codeunit 80 Sales-Post.
- Codeunit 22 Item Jnl.-Post Line.
But Code is changing for a while and following are changes -
1. During Sales order posting in Codeunit 80, Item Journal line record is inserted using a function in Table 83 "Item Journal Line" - CopyFromSalesHeader where Microsoft has added an event "OnAfterCopyItemJnlLineFromSalesHeader" that can be Subscribe to transfer custom values as shown below.
2. Item Ledger Entries are inserted via Codeunit 22 using the function "InitItemLedgEntry". Microsoft has added an event "OnAfterInitItemLedgEntry" that we can Subscribe to Transfer Custom values as shown below.
Lot's of theory, Let's add those two subscribers and respective code in our subscriber Codeunit created in the last article.
1. Add new subscriber in the same Codeunit using snippet teventsub to get the skeleton of the subscriber as shown below.
Lets assign parameters -
- Object Type - Table.
- Database::"Item Journal Line"
- OnAfterCopyItemJnlLineFromSalesHeader - Event that we want to subscriber.
- '' - This parameter only applies to Table Fields.
- TRUE
- TRUE
- TransferSourceofSalesToJournalLine - Function Name that we want to name the function.
Add all available parameters to Function / Procedure (as discussed in last article).
2. Add new subscriber in the same Codeunit using snippet teventsub to get skeleton of subscriber as shown below.
Lets assign parameters -
- Object Type - Codeunit.
- Codeunit::"Item Jnl.-Post Line"
- OnAfterInitItemLedgEntry - Event that we want to the subscriber.
- '' - This parameter only applies to Table Fields.
- TRUE
- TRUE
- TransferSourceofSalesToLedger - Function Name that we want to name the function.
Add all available parameters to Function / Procedure (as discussed in last article).
The Newly added subscribers with the code will look like as below.
With this, the functionality that customer asked for is ready to be used. In Next article, we will test this functionality after Publishing modified extension.
Stay Tuned for more and please add comments if any questions/suggestions.
Regards,
Saurav Dhyani
www.sauravdhyani.com
No issues, easy to follow. Just new to VS codes and all these AL syntax. Great Job Saurav
ReplyDeleteThanks for the comment @ibrahim. Great to hear that you liked the content.
DeleteNicely explain sir ......
ReplyDeleteWelcome @Bhagwan Chede Sir.
DeleteThanks a lot....This blog helped to fend off the fear of new changes in NAV/BC.
ReplyDeleteThis was very helpful to me, thank you for explaining it so well.
ReplyDelete