I'm trying to create Sales Line from code but the Line Amount keeps defaulting to => this.PriceUnit * this.SalesQty
Here is my formula:
Line amount is normally calculated by the systems from other fields - it seems that the standard calculation executes after your code. Or maybe it's updated by another customization?
Why do you want to use your calculation instead of the standard one (which is more sophisticated)? Because something in your system has broken the standard calcuLATION and you're trying to calculate things by yourself instead of locating and fixing the actual problem?
line amount/discount calculation works fine on the standard one Martin.
I was finding it difficult creating a sales line item using the SalesLineV2 entity (no single example on the internet on how to make use of the data entity), so i had to create a custom table that mirrors the required fields in the SalesLine table and exposed it.
Writing to the SalesLine table using the data entity of the custom table works fine but the LineAmount is not calculating even when the Discount is present.
Here's my code:
There are several different points to address.
Martin Dráb said:You said the standard calculation works fine and also that LineAmount is not calculating. I'm not sure how I should understand it.
I mean this works fine when I go through the Sales Orders list page and drills down on the Sales Order and then clicks on the "Add line" on the sales line grid to add a sales line
Martin Dráb said:You forgot to attach a tag with your version of AX. It is a good guess that you mean SalesOrderLineV2Entity in D365FO when you talk about SalesLineV2?
I'm on D365 F&O, Yes I mean SalesOrderLineV2Entity.
Microsoft needs to do better with examples on how to consume these OOB data entities, it can be really really frustrating when you're trying to call the endpoint and its not just working...