Form's DataSource Activated EventHandler in x++

 Form's DataSource Activated EventHandler in x++

/// <summary>

    ///

    /// </summary>

    /// <param name="sender"></param>

    /// <param name="e"></param>

    [FormDataSourceEventHandler(formDataSourceStr(CBLCartonsInfo, CBLCartonsHeader), FormDataSourceEventType::Activated)]

    public static void CBLCartonsHeader_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

    {


        FormDataSource              cblCartonsheader_ds     = sender.formRun().dataSource(formDataSourceStr(CBLCartonsInfo, CBLCartonsHeader));

        CBLCartonsHeader            cblCartonsheader        = cblCartonsheader_ds.cursor();

        

        FormDataSource              CBLCartonsInfo_ds     = sender.formRun().dataSource(formDataSourceStr(CBLCartonsInfo, CBLCartonsInfo));

        CBLCartonsInfo              CblCartonsInfo        = CBLCartonsInfo_ds.getFirst() as CBLCartonsInfo;


        InventJournalTable          InventJournalTable;


        real UnpostQty = 0;


        while (CblCartonsInfo.RecId != 0)

        {

            UnpostQty           = UnpostQty + CBLCartonsInfo.Qty;

            CBLCartonsInfo      = CBLCartonsInfo_ds.getNext();

        }



        if (cblCartonsHeader.InventJournalId  == '')

        {

            

            CBLCartonsHeader.UnPackedQty = UnpostQty;

        }

        else if(cblCartonsHeader.InventJournalId  != '')

        {

            select InventJournalTable where InventJournalTable.JournalId == cblCartonsheader.InventJournalId;

            if(InventJournalTable.Posted == NoYes::No)

            {

               

                CBLCartonsHeader.UnPackedQty = UnpostQty;

                

            }

            else

            {

                

                CBLCartonsHeader.UnPackedQty = 0;

            }

        }


    }

Comments

Popular posts from this blog

D365FO – AX – X++ –Refresh, Reread, Research, and ExecuteQuery

Create Inventory Journal through Code in D365FO X++

SalesLine Reservation in D365fo x++