web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Menu item button not working for class

(0) ShareShare
ReportReport
Posted on by 1,836

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 .

I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Dinesh,

    Can you show us the code and what error you are getting?

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    1,836 on at

    i am not able to paste my code here in code editor 

    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.addField(extendedTypeStr(transDate));
    dialogtransDate.label("TransDate");

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

    dialogMerchantId = dialog.addField(extendedTypeStr(trvExpMerchantId));
    dialogMerchantId.label("TransDate");

    dialogamountCurr = dialog.addField(extendedTypestr(TrvTransactionCurrencyAmount));
    dialogamountCurr.label("AmountCurr");

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

    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
    }
    }

    }

  • Dineshkarlekar Profile Picture
    1,836 on at

    public final class DK_EXPUpdate
    {
        
        /// 
        ///
        /// 
        /// 
        /// 
        [FormControlEventHandler(formControlStr(TrvExpenses, DT_EditButton_DK), FormControlEventType::Clicked)]
        public static void DT_EditButton_DK_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            Args args = new Args() ;
    
            DocuRef _DocuRef ;
            FormRun _formRun = sender.formrun() as FormRun ;
    
            FormDataSource _ds ;
            _ds =sender.formRun().dataSource(1);
            _DocuRef = _ds.cursor();
    
            args.record(_DocuRef);
            // calling menu item
            new MenuFunction(identifierstr(DT_UpdateMnu_DK), MenuItemType::Action).run(args);
        }
    
    }

    this on for click on edit i am getting object refrence is not set to an instance of object.

  • Dineshkarlekar Profile Picture
    1,836 on at

    I want to pass the records in table name taxexpences line in this dialogue

    if i select first line the field and their value should show in this dialogue how can i get this done am i going right ? plz help me out on this

    thanks

    regards

    dinesh

  • Dineshkarlekar Profile Picture
    1,836 on at

    I want to pass the records in table name taxexpences line in this dialogue

    if i select first line the field and their value should show in this dialogue how can i get this done am i going right ? plz help me out on this

    thanks

    regards

    dinesh

  • GirishS Profile Picture
    27,827 Moderator on at

    Why are you calling the menu item on the clicked button on the form - Creating menu item button - Mapping the action menu item name and DataSource is enough for your scenario - You will get caller object in the main method of RunBase class.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Dinesh, If you want to pass trvexpenses table buffer then why are you using DocuRef table in code? Are you getting error in line#19?

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    You can get the caller record in the main method of the run base class - Create one parm method in the run base class - Pass the caller record to that parm method you created - In the object method use addFieldValue method to set default value for the dialog - Value for assigning the dialog field - you can get it from the parm method.

    Refer to the below blog.

    https://d365ffo.com/2021/06/08/ax-d365ffo-add-a-default-value-to-a-dialog-field-in-a-runbase-dialog-or-runbasebatch/

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    1,836 on at

    hi

    Girish S.

    thanks for reply

    can u please explain what changes i need to do in my click what should i replace so i can get the desired output

    new MenuFunction(identifierstr(DT_UpdateMnu_DK), MenuItemType::Action).run(args);

    should i need to change this line 

    thanks 

    regards

    dinesh

  • GirishS Profile Picture
    27,827 Moderator on at

    Please see my previous reply - I can't understand what the purpose is of adding code in the clicked method.

    Please see my previous replies and see if it meets your scenario.

    Thanks,

    Girish S.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans