Bojensen Blogs

SalesLine « ErpCoder

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.

Dynamics AX 2009 Update Order Lines

Create a new field called "SalesNotes” in the SalesTable and SalesLine

Add the SalesTable.SalesNotes field to the Field Group HeaderToLineUpdate at the SalesTable
Put Sales Notes field HeaderToLineUpdate group in 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));

Modify the SalesTable2LineField.lineUpdateDescription method

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
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.

Modify the SalesNote value in a sales order

Review the update on the sales line

SalesLine « ErpCoder

Comments are closed.