Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Menu item button not working for class

Posted on by 1,457

I have created a menu item button on my form to which i have added the action menu item  i need to call the action menu item on the on click event of the button but i am getting error it should open the dialogue form on click of menu item button i dont know why i am getting error here can anyone pls guide me on this .

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    RE: Menu item button not working for class

    hi ,

    Girishs

    Mohit 

    thanks for helping me out 

     the dialog form is working fine 

    thanks 

    regards 

    Dinesh 

  • Verified answer
    GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Menu item button not working for class

    By default, it will open the dialog with first record in the form because the mouse pointer will be on the first record in the grid. You can use multiselect helper class on the clicked method to get the selected record and pass as the caller record. Try using multiselect helper and see if it works.

    Refer to the below blog.

    https://community.dynamics.com/365/financeandoperations/b/daxmusings/posts/multi-select-on-form-datasource-grid-multiselectionhelper

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    RE: Menu item button not working for class

    the dilogue box is taking the values from lines but i want it to only take value if i select the perticular line in grid but now it is taking the data from line before selection if i do not select the line it the dialog should appar blank.

    what i have to do to make it like that can u please guide me on this.

  • Verified answer
    GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Menu item button not working for class

    Don't user dialog.addFieldValue method instead just use dialogMerchantId.value(this.parmTrvExpTrans().MerchantId)).

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    RE: Menu item button not working for class

    hi

    girish s

    i am using this code and the diloge box is opening but its not passing the selected lines value in the dilog

    sorry the debugger is not working

    PUBLIC class DT_UpdateDialoge_DK extends RunBase
    {

    DialogField dialogtransDate;
    DialogField dialogcostType;
    DialogField dialogMerchantId;
    DialogField dialogVatID;
    DialogField dialogamountCurr;

    TrvExpMerchantId trvExpMerchantId;
    TrvExpMerchantId trvExpMerchantIdVatID;
    TrvTransactionCurrencyAmount currencyAmount;
    TrvDateStd transDate;
    TrvCostTypeEDT costType;
    FormDataSource formDataSource;
    TrvExpTrans expTrans;

    public static void main(Args _args)
    {
    DT_UpdateDialoge_DK demoDialog = new DT_UpdateDialoge_DK();
    // Display the dialog. This only returns true if the the user clicks "Ok" and validation passes.
    TrvExpTrans expTransBuffer = _args.record();
    demoDialog.parmTrvExpTrans(expTransBuffer);

    if (demoDialog.prompt())
    {
    //Logic when Ok is clicked goes here
    }
    }

    public TrvExpTrans parmTrvExpTrans(TrvExpTrans _expTrans = expTrans)
    {
    expTrans = _expTrans;

    return expTrans;
    }

    Object dialog()
    {
    Dialog dialog = super();
    ;
    dialog.caption("Update Line");
    dialog.addTabPage("Tab page");
    DialogGroup dialogGroup = dialog.addGroup("Dialog group");
    // Add a field for a name to the dialog. This will populate the field with
    // any value that happens to be saved in name from previous uses of the
    // dialog.
    dialogtransDate = dialog.addFieldValue(extendedTypeStr(transDate),'',"TransDate");

    dialogcostType = dialog.addFieldValue( extendedTypeStr(TrvCostTypeEDT),'',"Expence Catagory");

    dialogMerchantId = dialog.addFieldValue(extendedTypeStr(trvExpMerchantId),'',"Merchant");

    dialogVatID = dialog.addFieldValue(extendedTypestr(TrvExpMerchantId),'',"Merchant VatID");

    dialogamountCurr = dialog.addFieldValue(extendedTypestr(TrvTransactionCurrencyAmount), '',"Transaction Amount");


    return dialog;
    }

    }

    but when i use this code i get error on costtype an i am getting record in args.record but dont know how to pass it in dialog field 

    can you plz help me out on this.

    dialogtransDate = dialog.addField(extendedTypeStr(transDate));
    dialogtransDate.label("TransDate");
    
    dialogcostType = dialog.addField(this.costType);
    dialogcostType.label("Expence Catagory");
    
    dialogMerchantId = dialog.addField(extendedTypeStr(trvExpMerchantId));
    dialogMerchantId.label("Merchant");
    dialogMerchantId.value(this.parmTrvExpTrans().MerchantId);
    
    dialogamountCurr = dialog.addField(extendedTypestr(TrvTransactionCurrencyAmount));
    dialogamountCurr.label("Transaction Amount");
    
    dialogVatID = dialog.addField(trvExpMerchantIdVatID);
    dialogVatID.label("VatID");

  • GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Menu item button not working for class

    Please refer to below code. Seems code editor is not working. I am pasting the code directly.

    class DT_UpdateDialoge_DK extends RunBase
    {
    TrvExpTrans expTrans;
    public static void main(Args _args)
    {
    DT_UpdateDialoge_DK demoDialog= new DT_UpdateDialoge_DK();
    TrvExpTrans expTransBuffer = _args.record();
    demoDialog.parmTrvExpTrans(expTransBuffer);
    // Display the dialog. This only returns true if the the user clicks "Ok" and validation passes.
    if (demoDialog.prompt())
    {
    //Logic when Ok is clicked goes here
    }
    }

    public TrvExpTrans parmTrvExpTrans(TrvExpTrans _expTrans = expTrans)
    {
    expTrans = _expTrans;

    return expTrans;
    }

    Object dialog()
    {
    Dialog dialog = super();
    ;
    dialog.caption("Update Line");
    dialog.addTabPage("Tab page");
    DialogGroup dialogGroup = dialog.addGroup("Dialog group");
    // Add a field for a name to the dialog. This will populate the field with
    // any value that happens to be saved in name from previous uses of the
    // dialog.
    dialogtransDate = dialog.addField(extendedTypeStr(transDate));
    dialogtransDate.label("TransDate");

    dialogcostType = dialog.addField(costType);
    dialogcostType.label("CostType");

    dialogMerchantId = dialog.addField(extendedTypeStr(trvExpMerchantId));
    dialogMerchantId.label("TransDate");
    dialogMerchantId.value(this.parmTrvExpTrans().MerchantId);
    dialogamountCurr = dialog.addField(extendedTypestr(TrvTransactionCurrencyAmount));
    dialogamountCurr.label("AmountCurr");

    dialogVatID = dialog.addField(trvExpMerchantIdVatID);
    dialogVatID.label("VatID");

    return dialog;
    }
    }

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    RE: Menu item button not working for class

    Ihave made changes in my code now please tell me where i have to add that method to call the select line 

    PUBLIC class DT_UpdateDialoge_DK extends RunBase
    {

    DialogField dialogtransDate;
    DialogField dialogcostType;
    DialogField dialogMerchantId;
    DialogField dialogVatID;
    DialogField dialogamountCurr;

    TrvExpMerchantId trvExpMerchantId;
    TrvExpMerchantId trvExpMerchantIdVatID;
    TrvTransactionCurrencyAmount currencyAmount;
    TrvDateStd transDate;
    TrvCostTypeEDT costType;
    FormDataSource formDataSource;


    Object dialog()
    {
    Dialog dialog = super();
    ;
    dialog.caption("Update Line");
    dialog.addTabPage("Tab page");
    DialogGroup dialogGroup = dialog.addGroup("Dialog group");
    // Add a field for a name to the dialog. This will populate the field with
    // any value that happens to be saved in name from previous uses of the
    // dialog.
    dialogtransDate = dialog.addFieldValue(extendedTypeStr(transDate),'TransDate',"TransDate");

    dialogcostType = dialog.addFieldValue( extendedTypeStr(TrvCostTypeEDT),'',"Expence Catagory");

    dialogMerchantId = dialog.addFieldValue(extendedTypeStr(trvExpMerchantId),'',"Merchant");

    dialogVatID = dialog.addFieldValue(extendedTypestr(TrvExpMerchantId),'',"Merchant VatID");

    dialogamountCurr = dialog.addFieldValue(extendedTypestr(TrvTransactionCurrencyAmount), '',"Transaction Amount");

    return dialog;
    }

    public static void main(Args _args)
    {
    DT_UpdateDialoge_DK demoDialog = new DT_UpdateDialoge_DK();
    // Display the dialog. This only returns true if the the user clicks "Ok" and validation passes.
    if (demoDialog.prompt())
    {
    //Logic when Ok is clicked goes here
    }
    }

    }

  • GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Menu item button not working for class

    Also, instead of addFieldValue method you can directly use value method in the DialogField.

    dialogMerchantId(this.parmTrvExpTrans().MerchantId);

    Thanks,

    Girish S.

  • GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Menu item button not working for class

    Thats what I am saying no need of clicked method on the control - Just set the Menu item name and Datasource property on the menu item button - On the main method get the caller record - Create a parm method - Pass the caller record to the parm method - Set the default value in the dialog method using addFieldValue. Please refer to the blog I share for the reference.

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,547 Super User 2024 Season 1 on at
    RE: Menu item button not working for class

    Create parm methods in runbase class for MerchantId and VatId. In the main method, you can get trvExpTrans table buffer by using _args.record(). Set parm method value from this table buffer.

    To retrieve the value, Girish has shared blog, you can use that can call the parm methods in addFieldValue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans