D365

   [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]

    public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

    {

        SalesTable salesTable;

        SalesLine salesLine;

        container salesIds;

        while select * from salesTable where salesTable.SalesStatus==SalesStatus::Backorder && salesTable.ShippingDateConfirmed == today()+3 && salesTable.Scheduled == 1

        {

            salesIds+=salesTable.SalesId;

        }


        for (int i=1 ; i<=conLen(salesIds);i++)

        {

            while select * from salesLine where salesLine.SalesId == conPeek(salesIds,i)

            {

                Qty onOrder = salesLine.onOrderInSalesUnit();


                if(onOrder)

                {

                    ttsbegin;

                    select forupdate salesTable where salesTable.SalesId == conPeek(salesIds,i);

                    salesTable.PartialDelivery = NoYes::Yes;

                    salesTable.update();

                    ttscommit;

                    break;

                }


                if (onOrder == 0)

                {

                    ttsbegin;

                    select forupdate salesTable where salesTable.SalesId == conPeek(salesIds,i);

                    salesTable.PartialDelivery = NoYes::No;

                    salesTable.update();

                    ttscommit;

                

                }

            }

        }

           

        

    

    }


Comments

Popular posts from this blog

how to post trade agreement journals automatically using x++ code

How to Create a wizard in x++ d365

x++ code to submit and approve and reject the invent movement workflow in d365 F&O