Thursday, November 14, 2019

How to pass the argument from One form to another Form on Button click in D365FO X++

Form 1 on Button Click :
 [FormControlEventHandler(formControlStr(InventItemPrice, KMTItemPriceBreakdownForm), FormControlEventType::Clicked)]
    public static void KMTItemPriceBreakdownForm_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        Args            args = new Args();
        MenuFunction    menuFunction;
 
        InventItemPrice inventItemPrice = sender.formRun().dataSource("ItemPriceActivated").cursor();
        args.record(inventItemPrice);
        menuFunction = new MenuFunction(menuitemDisplayStr(KMTItemPriceBreakdownForm), MenuItemType::Display);
        menuFunction.run(args);



Form 2 on Init:
 [DataSource]
    class KMTInventItemPriceBrkdwn
    {
        public void init()
        {
            super();
            if(element.args().menuItemName() == menuItemDisplayStr(KMTItemPriceBreakdownForm))
            {
                 InventItemPrice kmtinventItemPrice = element.args().record();
                KMTInventItemPriceBrkdwn_ds.query().dataSourceTable(Tablenum(KMTInventItemPriceBrkdwn)).addRange(fieldNum(KMTInventItemPriceBrkdwn,ItemId)).
                    value(SysQuery::value(kmtinventItemPrice.ItemId));
            }
        }
}

5 comments:

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...