This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
|
|
|
|
|
|
This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
|
A common requirement in projects is that sales order lines should be created by code, such as data imports or similar.
Recently I had the request that code-generated sales order lines are then to be processed manually, but the price information such as sales price and rebate should be preserved.
However, editing certain fields in a sales order line in Dynamics AX triggers price search. This had to be prevented or pointed out to the user at least by a query. Fortunately, there is already one such query, which is controlled by the following fields:
If you manually override the price in a sales order line, AX will take care of filling these fields and mark the price information as manually changed.
For example, if you change the order quantity, the following dialog opens:
Whether this dialog opens is controlled by Accounts receivable parameters > Prices > Trade agreement evaluation.
However, the above fields are only filled by AX in certain circumstances. You have to explicitly take care of these fields when creating a sales order line by code.
If you do not do this, the pricing information written by code will be overwritten if anything happens with the sales order line triggers a price search.
Below you will find a few examples of how to create a sales order line by code, setting the fields in such a way that if the price-relevant fields in the item change, the dialog described above opens. In all these examples, I act as if the prices had been entered manually, which is controlled by the BaseEnum PriceDiscSystemSource.
Create a sales order line using AxSalesLine
For each manually populated price field, the method setPriceDiscChangePolicy() must be called.
Create a sales order line using SalesLine.create()
For each manually populated price field, the method setPriceDiscChangePolicy() must be called.
Incidentally, the above described applies not only to sales order lines, but also, for example, to purchase order lines.
Create a purchase order line using AxPurchLine
More detailed information can also be found in the document "Trade agreement evaluation policies in Microsoft Dynamics AX 2012".