Extend SalesTable2Line Framework

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

  1. Create a new field called "SalesNotes” in the SalesTable and SalesLine
  2. Add the SalesTable.SalesNotes field to the Field Group HeaderToLineUpdate at the SalesTable
    Put Sales Notes field HeaderToLineUpdate group in the SalesTable
  3. Display the new fields in the SalesTable form e.g. in the General tab
  4. 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.
  5. 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

     

  6. 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;
    }

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

  8. 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());
        }
    }

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

Advertisements

Über erpcoder
Software Engineer and Dynamics AX enthusiast working in Research & Development for InsideAx

7 Responses to Extend SalesTable2Line Framework

  1. Stefan says:

    oh that’s easy! thank you!

  2. Stefan says:

    oh, that’s easy! thank you!

  3. jie889 says:

    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

  4. Fabio Filardi says:

    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

  5. Pingback: Extend PurchTable2Line Framework (AX 2012) | ErpCoder

  6. taral says:

    this is really helpfull!! thanks

  7. Pingback: Extend the PurchRFQTable2Line Framework (AX 2012) | ErpCoder

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: