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

Disable button from code

(0) ShareShare
ReportReport
Posted on by 15

I want to enable or disable a Menu Item Button in a form where there are four tables associated. Based on the fourth table and condition where value is greater than 0 only than the menu item button is enabled else disabled. Please kindly guide me for the same

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi ankitrsharma,

    You could put codes:

    if(condition){

    menuitemname.enabled(false)

    }

    on Form.Init() method of your form.

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

    Title changed from "Technical help" to "Disable button from code". Category changed from "Manufacturing" to "Development / Customization / SDK".

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

    Doing it from init() method wouldn't do the job - it would happen just once, when starting the form. You want to use active() method of a data source.

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Put following code in the active method of the data source of the fourth table:

    MyButton.enabled(MyTable.MyField > 0);

  • ankitrsharma Profile Picture
    15 on at

    Thanks Will. But I have to enable or disable a menu item button. Condition is based on the field jump ref form value. Eg. Transfer order there are two grids INVENTTRANSFERTable and InventTransferLine. Hence if we go to the InventTransferLine table and from there we select the InventDim. WMSPalletID. When we view the details of the WMSPalletID it directs to the WMSPallet form and there we have customized field. On the basis of that field value i need to enable disable the button. Can you kindly guide me for the same. Thanks.

  • ankitrsharma Profile Picture
    15 on at

    ok sir thanks for the help

  • ankitrsharma Profile Picture
    15 on at

    you are correct sir. I am doing the same but the condition is

    But I have to enable or disable a menu item button. Condition is based on the field jump ref form value. Eg. Transfer order there are two grids INVENTTRANSFERTable and InventTransferLine. Hence if we go to the InventTransferLine table and from there we select the InventDim. WMSPalletID. When we view the details of the WMSPalletID it directs to the WMSPallet form and there we have customized field. On the basis of that field value i need to enable disable the button. Can you kindly guide me for the same. Thanks.

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    MyButton.enabled(WMSPallet::find(inventTransferLine.InventDim().WMSPalletId).MyField > 0);

    (replace inventTransferLine.InventDim() with inventDimShip() or inventDimReceive() if needed).

    By the way, perhaps next time you can share all the details already in your first message - this way others can provide more accurate suggestions and you solve your issue quicker.

  • ankitrsharma Profile Picture
    15 on at

    Hi Nikolaos. Thanks for the same. But the condition is as below.

    Thanks Will. But I have to enable or disable a menu item button. Condition is based on the field jump ref form value. Eg. Transfer order there are two grids INVENTTRANSFERTable and InventTransferLine. Hence if we go to the InventTransferLine table and from there we select the InventDim. WMSPalletID. When we view the details of the WMSPalletID it directs to the WMSPallet form and there we have customized field. On the basis of that field value i need to enable disable the button. Can you kindly guide me for the same. Thanks.

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    You don't need to repeat the same thing over and over, everyone can see all messages that you post.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans