Followers

Showing posts with label How to update the fields in form with parameter through menu item button in D365. Show all posts
Showing posts with label How to update the fields in form with parameter through menu item button in D365. Show all posts

6 October 2020

How to update the fields in form with parameter through menu item button in D365

Req : Update the field in Table(InventdimCombination )Form "EcoResProductVariantPerCompany". 

develop an RFA Flag(Custom field) button on the Released Product Variants screen under the Product variants option. When the button is clicked a new window will open which will allow the user to select RFA Flag toggle. 

The user should be able to select a single or multiple product variants on screen and update the RFA status to Yes (Active) or No (Inactive).

Product Information Management à Released Products à Product à Product Master à Released Product Variants 





Sol : Created Menu item button (Modify RFA enabled) and Class. attached the class to menu item. 

        

Select the item number and click the button will open the dialog with parameter , so user will select the value (Yes /No), then click OK , will update the parameter value in form.


        class RFAEnabledDialog extends RunBaseBatch

{

    DialogField fieldAccount;

    NoYesId     rfaenabled;

   

    public Object Dialog()

    {

        Dialog dialog;

        ;

        dialog = super();

        dialog.caption( 'Modify RFA Enabled');

        fieldAccount = dialog.addField(enumstr(NoYesId),'RFA Enabled');

        return dialog;

    }


    public boolean getFromDialog()

    {

        rfaenabled = fieldAccount.value();

        return super();

    }


    public void run(InventDimcombination inventdimcombination =null)

    {

        ttsbegin;

        if(inventdimcombination)

        {

            inventDimCombination.selectForUpdate(true);

            inventDimCombination.RFAEnabled = rfaenabled;

            inventDimCombination.update();

        }

        ttscommit;

    }


    public static void main(Args _args)

    {

        RFAEnabledDialog       rFAEnabledDialog = new RFAEnabledDialog();

        InventDimCombination      inventDimCombination;

        FormDataSource            fds_ds;

        Formrun                   formRun;


        if (rFAEnabledDialog.prompt())

        {

            formRun = _args.caller();

            fds_ds = formRun.dataSource();

            MultiSelectionHelper helper = MultiSelectionHelper::construct();

            helper.parmDatasource(fds_ds);

            inventDimCombination = helper.getFirst();

            while (inventDimCombination.RecId != 0)

            {

                rFAEnabledDialog.run(inventDimCombination);

                inventDimCombination = helper.getNext();

            }

           

        }

    }


}

O/P :