0

I have recently found an interesting article about using .NET Microsoft.Dynamics.Commerce.Runtime.Services.PricingEngine.PricingEngine to calculate the price and discount for an order: (https://community.dynamics.com/365/financeandoperations/b/kurthatlevik/posts/dax2012-r3-playing-with-retail-crt)

I modified the author's code by adding these two lines at the end of the job to get the total amount and the total number of items of the order (off course, I already changed my ItemId and InventDimId to values which are suitable with my AX 2012 R3 system):

Price = crtSalesTransaction.get_TotalAmount();
qty = crtSalesTransaction.get_NumberOfItems();

All I received are 0s.

I tried to check the MS document about the class, but the information there is quite limited (https://learn.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/pricingengine-methods-microsoft-dynamics-commerce-runtime-services-pricingengine). I also tried all other related methods of the class Microsoft.Dynamics.Commerce.Runtime.DataModel.SalesTransaction, but no luck. So I'm quite confused. Does the code need something more or is it a bug of AX? Could someone give me a hint?

Thank you.

Tuan Le PN
  • 364
  • 1
  • 12
  • Could you add the code to your question where the `crtSalesTransaction` variable is instantiated and sales lines are added to it? Do the other get methods from the linked article work for you (please [edit] your question to add the answer instead of answering in a comment)? – FH-Inway Mar 28 '21 at 05:47
  • The code is included in the article of the first url mentioned in my question. I just added the new two lines at the end of the job function. Other methods didn't work either. – Tuan Le PN Mar 29 '21 at 06:53
  • 1
    I suggest you test the code with Contoso data and an unmodified installation of AX to verify that the code from the article works. If it does, the issue is probably the data and/or some customization in your current environment. – FH-Inway Mar 30 '21 at 05:33

0 Answers0