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;

        }
    }

}

Comments