How to Extend Sales Order Update Functionality to Custom Fields in Dynamics AX
I worked on a feature to add custom fields in Dynamics AX to the sales order header and lines. With this customization, there was a requirement that if you were to update the custom field on the sales order header, the value would also transfer to all the sales lines. Dynamics AX already does this for some fields out-of-the-box. In this article, I will show you how you can extend this attribute to your custom fields.
Once you have added the fields to the SalesTable and the SalesLine table and exposed the fields on the SalesTable form, add the new custom field to the HeaderToLineUpdate field group on the SalesTable Table.
In order for the system to recolonize the sales order to line fields that need to be updated, the fields must be set to prompt, or always, in the Account Receivable parameters form. (Accounts receivable – Setup – Accounts receivable parameters – Updates – Update order lines (Button))
To add this field to the update order lines form, you will need to modify the lineUpdateDescription method in the SalesTable2LineField class. Add the following code highlighted below, replacing the SSI_TransDate field with your new custom field.
Once this is complete if you go back to the AR parameters form, you will now find your custom field listed on the Update order lines form. Note: make sure to mark the field as prompt.
The sales order line update process uses the sales order document service, so you will need to add some custom code for the system to copy the value from the sales header to the sales lines.
In the AxSalesTable class I added a new method:
The final piece to the puzzle is to add the set*YourCustomField* method to the setTableFields method in the AxSalesLine class:
Since you’re are modifying a service document, make sure to run an incremental CIL. But, once this is all complete you should find the sales order update functionality working for your custom fields.