Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Disable Button when Selecting Data

Posted on by 205

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.

Categories:
  • XSpy Profile Picture
    XSpy 205 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!

  • sohaibcheema Profile Picture
    sohaibcheema 46,590 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 205 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);

  • sohaibcheema Profile Picture
    sohaibcheema 46,590 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 205 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.

  • sohaibcheema Profile Picture
    sohaibcheema 46,590 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.

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,632 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,528 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans