Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Disable Button when Selecting Data

Posted on by 207

Hello All,

I need help here.

1817.Q.png

Warehouse management > Common > Load planning workbench

If the Load Status is "Open", then the Release Button must be Enabled (Default)
If the Load Status is Not "Open", then the Release Button must be Disabled. 

must be triggered upon clicking a data.

is this possible? 

Please help, thanks.

*This post is locked for comments

  • XSpy Profile Picture
    XSpy 207 on at
    RE: Disable Button when Selecting Data

    yes thanks for the answers, i'll try to put it in every Datasource to try it. Thanks!

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Disable Button when Selecting Data

    we are not sure about status field which is appearing in upper part, as system is in your hand; whether that belongs to WHSLoadTable or some other Datasource

    Or may be it is because of upper gird is bound to another dataSource.

    from your above screenshot(1st one) it seems that it may be part of SalesLine

  • XSpy Profile Picture
    XSpy 207 on at
    RE: Disable Button when Selecting Data

    Thanks Sohaib Cheema, Bhaskar Roy!

    the code works,

    but there's one more flaw here. 

    1273.W.png

    the WHSLoadTable is linked in the bottom part of the Form (Loads).

    the Load status in the upper part is also part of WHSLoadTable, but the active method only works in the bottom part of Form.

    i need it to work in the upper Load status, not the bottom one.

    *im trying the code : 

    ReleaseMenuButton.enabled(WHSLoadTable.LoadStatus == WHSLoadStatus::Open ? true : false);

    in other DataSource to see if it might work, but might as well ask if you know where to put it.

  • Verified answer
    5400 Profile Picture
    5400 7,160 on at
    RE: Disable Button when Selecting Data

    Please go to

    \Forms\WHSLoadPlanningWorkbench\Designs\Design\[Tab:DemandLoadsTab]\[TabPage:TabLoad]\[ActionPane:ActionPaneLoad]\[ActionPaneTab:ActionPaneTabLoad]\[ButtonGroup:Info]\[MenuButton:ReleaseMenuButton] -

    ReleaseMenuButton - do autodeclartion yes.

    \Forms\WHSLoadPlanningWorkbench\Data Sources\WHSLoadTable\Methods\active-- before return write below code

    ReleaseMenuButton.enabled(WHSLoadTable.LoadStatus == WHSLoadStatus::Open ? true : false);

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Disable Button when Selecting Data

    check if there is existing active method on datasource; if not do override it by right clicking methods node of datasource, and then write code after super() as under

    if(condition)

       {

           ButtonName.enabled(true);

       }

       else

       {

           ButtonName.enabled(false);

       }

  • XSpy Profile Picture
    XSpy 207 on at
    RE: Disable Button when Selecting Data

    the Release button is always Enabled, I just want to add the Disable function.

    can you help me with the code? thanks.

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Disable Button when Selecting Data

    of course, on any form buttons can be enabled/disabled by writing code at active() method.

    But, very important thing is to know/read existing logic. how your code will behave in combination with existing business process? are those buttons already being enabled/disabled by any business process? these questions must be answered before you start writing code at active() method.

    sometimes form(s) do have a interaction class, where the buttons enable/disable is being handled based on many aspects, those need review.

    it is not about possible/impossible. its about reading your customization in combination with existing business process.

  • Suggested answer
    5400 Profile Picture
    5400 7,160 on at
    RE: Disable Button when Selecting Data

    Yes,It is possible. you can achiev through active method which will be good pratice this type scenarion. But if you want through button click also possible.

    Make release button - as autodiclartion yes

    and put the logic.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans