Showing posts with label code to compare origincal values. Show all posts
Showing posts with label code to compare origincal values. Show all posts

Tuesday, 22 October 2019

how to get original value of a table in Dynamics D365 ,ax 2012

how to get original record of a table in Dynamics D365 ,ax 2012

Hi all,
So in order to get the original record while updating any record in a table you will need the original/previously unchanged record to compare in some scenarios.
In that case you can use the below code as shown.

    public void update()
    {
        InventTable     this_Orig           = this.orig();
      
        ttsbegin;

       super();

      
        if (this_Orig.SalesModel                       != this.SalesModel              ||
            this_Orig.SalesPriceModelBasic      != this.SalesPriceModelBasic    ||
            this_Orig.SalesContributionRatio    != this.SalesContributionRatio  ||
            this_Orig.SalesPercentMarkup        != this.SalesPercentMarkup)
        {
            InventTable::updateAutoSalesPrice(this.ItemId);
        }
        ttscommit;
    }
thanks,
Vikas Mehta.

Blog Post 6: Bonus – Building Your First Custom Copilot Plugin in X++

Blog Post 6: Bonus – Building Your First Custom Copilot Plugin in X++  Introduction In our previous posts, we explored what Copilot can do o...