Followers

8 October 2020

Insert the field from Sales Table to WMSPickingRoute table in D365

 Insert the field from Sales Table to WMSPickingRoute table in D365 :

    Req : I have custom field (IsSalesRequierd) in sales table, so same field I need to develop in             WMSPickingRoute table also. This only when reference type as sales in picking route .

    Note : Only Insert 

    Sol :

    1) go to the WMSPickingRoute table > Events> On Inserting>right click> Copy event handler option

    2) Create class


    class WMSPickingRouteTable_EventHandler

    {

    [DataEventHandler(tableStr(WMSPickingRoute), DataEventType::Inserting)]

    public static void WMSPickingRoute_onInserting(Common sender, DataEventArgs e)

    {

        WMSPickingRoute         wMSPickingRoute = sender as WMSPickingRoute;

        SalesTable              salesTable;

        if(wMSPickingRoute.transType == InventTransType::Sales)

        {

            select firstonly IsSalesRequierdfrom salesTable

                where salesTable.SalesId == wMSPickingRoute.transRefId;


            wMSPickingRoute.IsSalesRequierd= salesTable.IsSalesRequierd;

           

        }


    }


}


    

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 :