Post sales order invoice in Dynamicso 365 for operation via code

Hello All:

In ax 2012 I successfully changed the status from Delivery to Invoice

public static void main(Args _args)
{
         SalesFormLetter salesFormLetter;
         SalesTable salesTable;
         changecompany('USMF')
         salesTable = SalesTable::find('000714');

        if (salesTable && salesTable.SalesStatus == SalesStatus::Delivered)
       {
           salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
           salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None, NoYes::No, NoYes::No,                NoYes::No, NoYes::Yes);
       }
       else
       {
             info(" Sales Id does not exists or null in the system, please try again!");
        }
}

The above code snippet works fine in Ax 2012 but doesn't work well in dynamics 365 for operations

Please help as quickly as you can

Thanks,

Shankar :)

Related
Recommended