Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to control opening/closing the form based on a certain condition

Posted on by 266
Hi,

I have a display menu item, when clicked it opens a dialog form.
Now this menu item appears on two tabs

When clicked on the first one, i want the dialog to appear as normal where i fill some fields then click ok (and there is some logic on the ok method)

But when this menu item is clicked from another tab, then i don't want the dialog to appear and fill some fields, i want to pass the value of one of the fields by code and run the logic on the ok method directly. how to do that?

 
Categories:
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,030 Most Valuable Professional on at
    How to control opening/closing the form based on a certain condition
    Let the menu item call a SysOperation controller class. There you can use parmShowDialog() to decide whether to show the dialog or not based on a condition. Using an enum parameter on the menu item button make sense to me. I would avoid overriding cllick() and putting the business logic there - having the logic in the controller makes it reusable.
  • Waed Ayyad Profile Picture
    Waed Ayyad 6,241 Super User 2024 Season 2 on at
    How to control opening/closing the form based on a certain condition

    Hi, 

    Is your issue resolved? If yes, mark the answers that helped you as verified. 

    Thanks,

    Waed Ayyad

  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,241 Super User 2024 Season 2 on at
    How to control opening/closing the form based on a certain condition
    Hi,
     
    Maybe you can set the ‘Enum Type Parameter‘and ‘Enum Parameter‘  on the menu item and check its value on the init method of the form.  Check the following blog for more details:
    https://dynamics365musings.com/how-to-send-enum-parameters-to-forms/
     
    But why you want to implement it in this way? You can simply on the first tab add the menu item and in the second tab use button control and override its clicked method and add the code that you want on it.
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue

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!

Community AMA December 12th

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

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans