Skip to main content

Notifications

Announcements

No record found.

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

Disable button from code

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

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Disable button from code

    You don't need to have a loop. You need a loop if you want to iterate multiple records. But in your situation you need to look for one record only: the first line that has value > 0. If that is found, you will enable your button, otherwise you will disable it.

  • ankitrsharma Profile Picture
    ankitrsharma 15 on at
    RE: Disable button from code

    Hi Nikolaos, You are correct. I want to enable the button if at least one line has value >0. Thanks. Just a question may be to silly but still let me ask it. If we work the code with header table do we need to have for loop in there. Thanks and regards, Ankit

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Disable button from code

    You didn't tell what you want to happen in that situation. Do you want to enable the button if at least one line has value > 0? Or do you want to enable only if all lines have value > 0?

    My code already shows how to get the value for one transfer order line. And my example shows hot to enable/disable a button via code.

    Once you have clarified this new requirement, I'm pretty sure you should be able to write code to achieve the desired functionality by applying what you have learned so far.

    Of course if your logic is not anymore related to exactly one line, it should not be in the active method of the line table. Maybe active method of the header table would be correct.

  • ankitrsharma Profile Picture
    ankitrsharma 15 on at
    RE: Disable button from code

    Hi Nikolaos, just one more thing if I need to check above condition for multiple pallets. For eg. I have 1 transfer order with two lines and with different pallet ID. what would be the code for if 1st line pallet id has the tare weight value >0 but the other line pallet value has tare weight value =0. In that case what can be the perfect code. please kindly guide. Thanks

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Disable button from code

    Hi, could you please mark the helpful answer(s) as verified to close the thread and make it easy for others to find verified information from the forum. Thanks!

  • ankitrsharma Profile Picture
    ankitrsharma 15 on at
    RE: Disable button from code

    Great answer. Thanks for the help. Surely I would keep that in mind launching new question. Please kindly suggest good books to increase my technical depth.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Disable button from code

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

  • ankitrsharma Profile Picture
    ankitrsharma 15 on at
    RE: Disable button from code

    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.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Disable button from code

    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
    ankitrsharma 15 on at
    RE: Disable button from code

    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.

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans