Extend SalesTable2Line Framework
28. October 2011 8 Comments
Dynamics AX provides a Framework for updating changes made on SalesTable fields to SalesLine fields. The update method can be configured within Dynamics AX at Accounts Receivable > Setup > Parameters > Updates > “Update order Line”. This form is used to configure if and how changes made to the SalesTable are written to the lines. This framework can be extended to update your own fields, like a “Notes” field in the example below.
- Create a new field called "SalesNotes” in the SalesTable and SalesLine
- Add the SalesTable.SalesNotes field to the Field Group HeaderToLineUpdate at the SalesTable
- Display the new fields in the SalesTable form e.g. in the General tab
- Open the SalesTable2LineParameters table in the table browser and remove all records. Don’t worry, these data will be populated automatically and is the basis for the “Update order line” form.
- Add the following line to the SalesTable2LineField.lineUpdateDescription method
case fieldnum(SalesTable, SalesNote):
return fieldid2pname(tableNum(SalesLine), fieldNum(SalesLine, SalesNote)); - Add a parameter method for the SalesNote field to the AxSalesTable class
public SalesNote parmSalesNote(SalesNote _salesNote = ”)
{
if (!prmisdefault(_salesNote))
{
this.setField(fieldnum(SalesTable, SalesNote), _salesNote);
}return salesTable.SalesNote;
} - Add a parameter method for the salesNote field to the AxSalesLine class
public SalesNote parmSalesNote(SalesNote _salesNote = ”)
{
if (!prmisdefault(_salesNote))
{
this.setField(fieldnum(SalesLine, SalesNote), _salesNote);
}return salesLine.SalesNote;
} - Create a setSalesNote method on the AxSalesLine class
protected void setSalesNote()
{
if (this.isMethodExecuted(funcname(), fieldnum(SalesLine, SalesNote)))
{
return;
}this.setAxSalesTableFields();
if (this.isAxSalesTableFieldsSet() || this.axSalesTable().isFieldModified(fieldnum(SalesTable, SalesNote)))
{
this.parmSalesNote(this.axSalesTable().parmSalesNote());
}
} - Modify the setTableFields method to call the setSalesNote method
- Test your modification. Open the “Update order line” form and set the update method for Sales Notes to “Prompt”. Open the sales order details form, go to your new field, modify the text and save. A dialog will appear and ask your to update the Note fields. Click OK, and review the Sales Notes in the SalesLines.
oh that’s easy! thank you!
oh, that’s easy! thank you!
Hi Markus,
I have tried to test this method in AX 2012, i got error which is “cannot edit a record in order line update parameters(salestable2lineparameters).” and the update order line form is looked strange no label showed. when I manual added records to the salestable2lineparameters, then it works again. can you tell me when then data insert to the table salestable2lineparmeters
thanks
jie
Hi jie.
This is because your SalesTable2LineParameter table is empty and the code can’t find the records to update. Maybe Microsoft should have prevented this, but we can do by ourself.
Just open the SalesTable2LineParametersForm class, and modify the “new” method, inserting a call to initiate() static method from SalesTable2LineParameters table. It should look like this:
void new()
{
super();
SalesTable2LineParameters::initiate();
this.initSalesTable2LineParameterFields();
}
If you have inserted any data by hands in this table, clean it again.
I hope this helps (probably will already found a solution)…
Regards
Pingback: Extend PurchTable2Line Framework (AX 2012) | ErpCoder
this is really helpfull!! thanks
Pingback: Extend the PurchRFQTable2Line Framework (AX 2012) | ErpCoder
Pingback: Extend SalesTable2Line Framework (Dynamics 365 Finance / SCM) | ErpCoder