Modified Event Hanlder Examples

// FormControlEventHandler 

 [FormControlEventHandler(formControlStr(VendTable, Payment_PaymMode), FormControlEventType::Modified)]

    public static void Payment_PaymMode_OnModified(FormControl sender, FormControlEventArgs e)

    {

        FormStringControl  callerButton = sender as FormStringControl ;  //Retrieves the button that we're reacting to

        FormRun element = callerButton.formRun();

        FormControl Payment = element.design(0).controlName("Payment_PaymTermId");

        if(callerButton.valueStr()=='CHECK')

        {

            Payment.allowEdit(false);

        }

else

        {

            Payment.allowEdit(true);


        }



    }

                     

Form Data source event handler:


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

        public static void SalesLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

        {

            SalesLine        salesLine   = sender.cursor();

            info(strFmt("%1", salesLine.ItemId));

        }


    Form Data Field event Handler :

        [FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesLine, ItemId), FormDataFieldEventType::Modified)]

        public static void ItemId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

        {

           

            FormDataSource salesLine_ds = sender.datasource();

        SalesLine salesLine = salesLine_ds.cursor();

        info(strFmt("%1", salesLine.ItemId));


        }


}


FormControlEventHandler Onmodified:

 [FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, CST_Identification_CST_ParentItemId), FormControlEventType::Modified)]

    public static void CST_Identification_CST_ParentItemId_OnModified(FormControl sender, FormControlEventArgs e)

    {

        CST_ItemSubMaster cST_ItemSubMaster;

        FormStringControl  callerButton = sender as FormStringControl; 

        FormDataSource fds = callerButton.formRun().dataSource(formDataSourceStr(EcoResProductDetailsExtended, InventTable));

        InventTable inventTable = fds.cursor();

        FormStringControl cst_ParentItemId = sender.formRun().design().controlName(formControlStr(EcoResProductDetailsExtended,CST_Identification_CST_ParentItemId));

        FormRun element = callerButton.formRun();


        update_recordset cST_ItemSubMaster

           setting ParentItem = cst_ParentItemId.valueStr()

           where cST_ItemSubMaster.ChildItem == inventTable.ItemId;

    }


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