AX / D365FO – Create a simple Note on a Table in X++

This example shows how to create a simple note on a Table (ie. SaleTable)

The code will insert a new note in the salesTable Form (like shown below)

Example code

class CreateNote
{

    public static void main(Args _args)
    {
        DocuRef             docuRef;
        DocuActionArchive   docuArchive;
        
        changeCompany('your company') 
        {
            SalesTable          salesTable = SalesTable::find("your order No.");

            ttsbegin;

            // Code to create notes
            docuRef.TypeId = 'Note';
            docuRef.Name = "Sales order notes";
            docuRef.Notes = "Sales Order Note description";
            docuRef.Restriction = DocuRestriction::External;
            docuRef.RefTableId = tableNum(SalesTable);
            docuRef.RefRecId = salesTable.RecId;
            docuRef.RefCompanyId = curext();
            docuRef.insert();

            ttscommit;

        }
    }

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s