Wednesday, October 7, 2015

Posting Preview in Dynamics NAV 2016 - Part 02 (Technical)

To read more about posting preview please check on my previous blog post. 
In this blog post I will be mainly focusing on the technical side of the posting preview functionality. 

Posting preview is providing posted transaction view on unposted entries and how this is even possible?

To find answer for the question we will have to go to development environment and look at how the things are been developed. 

Following are the main objects that are behind this new feature in Dynamics NAV 2016 

As you can see only codeunits and pages are available in here and no tables are involved in this! How that is even possible because each of these pages should have the source table and why those tables are not visible? That is another question that we need to find answers.

So let's design a page and go to it's properties to find the source table. 
OK!! Even though it answer to our second question this is strange because source table is set to G/L Entry table

Is that mean in the background does NAV post entries to G/L entry table and then delete them after preview is done? To find answer to that let's go down in the properties list of the page we designed. 

There goes the secret!  
SourceTableTemporary = YES

So that means Microsoft Does this with the help of temporary tables. To confirm our theory let's move to the codeunit (19 - Gen. Jnl.-Post Preview)  related to preview posting. 

Let's straightaway jump inside to the codeunit! 

It is a codeunit with 232 lines and now it is really easy to count lines since the line numbers are available in the new C/AL editor. 

If you go to global variables of the codeunit you will be able to see most of the well known tables are defined as a variables in there. 
To find the answer we required to check the properties of these variables, 

It is confirmed now! Tables are set as Temporary! Therefore any data that is been pushed to tables will not get saved. That is how Microsoft provide preview on posting in Dynamics NAV journals. 

It is a simple but really effective! 

Hope to see you all with an another blog post. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara

No comments:

Post a Comment