Monday, July 8, 2019

How to add document note in D365


class VendAccountDocument_JKS

{



    static void main(Args _args)

    {

        VendTable vendTable;

        DocuType docuType;

        DocuRef docuRef;

        vendTable = VendTable::find('BRMF-000001');

        docuType = DocuType::find('Note');

        if (!docuType ||

            docuType.TypeGroup != DocuTypeGroup::Note)

        {

            throw error("Invalid document type");

        }

        docuRef.RefCompanyId = vendTable.dataAreaId;

        docuRef.RefTableId = vendTable.TableId;

        docuRef.RefRecId = vendTable.RecId;

        docuRef.TypeId = docuType.TypeId;

        docuRef.Name = 'Automatic note';

        docuRef.Notes = 'Added from X++';

        docuRef.insert();

        info("Document note has been added successfully");

    }



}

No comments:

Post a Comment