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, ...
Suggested Answer

How to Disable MenuItem Button

(0) ShareShare
ReportReport
Posted on by 454

Hi,

I have to disable this Edit Button based on my requirement. I know how to do for normal Button. When i use The Name Of the Menuitembutton('Edit') in the code it takes as a Keyword 'Edit'. How to solve this?

pastedimage1581927177246v1.png

Regards,

Ram.

I have the same question (0)
  • Blue Wang Profile Picture
    on at

    HI Ram,

    You can refer to this DOC:docs.microsoft.com/.../how-to-enable-and-disable-an-action-pane-button-on-a-list-page

    Besides that , you can try to set security.

  • Ram Kumar Profile Picture
    454 on at

    Hi Blue Wang,

    In My Requirement there is no need to set security. Based on the text on the grid string edit control the Button Should be Disabled.

    Regards,

    Ram

  • Suggested answer
    Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    You're looking at the problem from the wrong perspective.

    Your actual goal isn't disabling the button, but making the datasource non-editable. To do that, change AllowEdit property of the datasources. Because you want to do it conditionally from code, get a reference to the right FormDataSource object and then call allowEdit(false).

  • Ram Kumar Profile Picture
    454 on at

    Hi Martin,

    My Actual Requirement is when the Value in the String edit control in the Grid == 'Something'. The Menuitem Button i have mentioned should be disabled. When You see this code Edit is the name of the button.But i cant use that control because Edit is a Keyword.

     if(AssetTable_AssetGroup.text()=='BUILDINGS')
        {
           Edit.enabled(true);
        }

    Regards,

    Ram.

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    The Edit button will be disabled when the data source is set not to be editable.

    Your can't work because there it no form control with Name = Edit. You're confusing UI labels with controls names.

  • Ram Kumar Profile Picture
    454 on at

    Hi Martin,

    See Here The Name Of the Button is Edit How can i Access this Control. That is what my problem now.

    pastedimage1581934462845v1.png

    Regards,

    Ram.

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    Aha, so this question is about a listpage, not a normal form. List pages aren't editable at all, therefore the button redirects you to another form.

    And you're trying to modify it as if it was a normal form and not a listpage. I see you added an additional datasource outside the query and you're trying to write code inside the listpage instead of the listpage interaction class. That's not the right approach.

    Please look at the link in Blue Wang's reply and related documentation pages to get some idea about how to use listpage forms. Feel free to ask if needed; now when we know what you're doing it'll be easier to help.

  • Ram Kumar Profile Picture
    454 on at

    Hi Martin,

    See the below image For Reference. My Condition is when the Fixed Asset Group is not equal to 'BUILDINGS' it should be Disabled. I Used Editingrid Button instead of Edit Button it works Fine. But i am unable to Access the Edit Button in my Code. Since it is a keyword ("Edit"). I Hope you understand with my images.

    pastedimage1581937919836v1.png

    pastedimage1581938046050v2.png

    Regards,

    Ram.

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    It still seems to me that you're doing a wrong thing.

    But yes, X++ keywords can't be used as variables names. If you want to refer to the button by its name in X++ through auto-declaration, it name mustn't be 'Edit'. Note that you can use other ways to get a reference to the control, such as this.design().controlName('Edit').

  • Ram Kumar Profile Picture
    454 on at

    Hi Martin,

    Here is my Code but when i run my code this throws an error Formrun object not initialized. 

            Args                    args = new Args();
            FormRun formrun;
            args.name(formstr(Assettablelistpage));
            formrun = classfactory.formRunClass(args);
       if(AssetTable_AssetGroup.text()!='BUILDINGS')
        {
          formRun.design().controlName(formControlStr(Assettablelistpage, Edit)).enabled(false);
        }
        else
        {
            formRun.design().controlName(formControlStr(Assettablelistpage, Edit)).enabled(true);
        }

    Regards,

    Ram

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 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans