In Microsoft Dynamics CRM 2011, we introduced the concept of UI Scripts (otherwise known as Dialogs) which are essentially workflows with the provision to accept inputs from the user. We call these as “Prompts and Responses”. I use the word provision lightly simply because it’s not really optional; rather it is mandatory to have at least one page with at least on Prompt and Response item in any given Dialog. If one didn’t then one would see the following error message on activation of the Dialog.
Screenshot: Error on activating a Dialog without any Prompt and Response Step
Why would one want to have Dialogs without pages instead of using Workflows?
- Well, for starters, Dialogs have Variables and Input Arguments that gives the flexibility in authoring the business processes. - Once a Workflow is linked from a Dialog, one will not be able to call back into a Dialog. - In addition, Workflows are asynchronous whereas Dialogs are synchronous.
Think of the scenario where in one needs to obtain some inputs from the user, do some backend processing before displaying the resulting information. In this case there would be a couple of Dialogs which require pages and there may be many more that only do some backend processing. The backend processing Dialogs are modules that do some unit of work and pass on the information to other modules. Authoring Dialogs in this modular fashion increases their re-usability.
Having more modules implies having more Dialogs which in turn implies we end up having more pages since each Dialog needs to have at least one page. Bummer! Not anymore! Here’s a simple trick that you probably already knew. - Add a Variable, say “Dummy” of type Single Line of Text. Set some default value, say “myworkaround”.Screenshot: Add a dummy variable
- Add a Check Condition step. The condition should read like this:
If Dummy’s Value is Not Equal To “myworkaround”.Screenshot: Check Condition : Is Value of Dummy Variable Not Equal to “myworkaround”?For the steps of the condition above add the following steps: - Add a Page. - Add a Prompt and Response with more dummy values.Screenshot: Add a dummy page and dummy Prompt and Response
Activate this Dialog as a Process Template. Henceforth, when one wants to create a new module Dialog, one creates it out of this template. Voila! We now have “Page-less” module dialogs.Okay, why do we call them “Page-less” when we have added a page and a “Prompt and Response”? You guessed it right; the page is never shown as the condition to show the page is never true. However, one is allowed to activate the Dialog because the authoring tool is satisfied with the presence of the “Dummy Page”.Now if only I could also get rid of the “Finish page” – I would have a truly “Page-less” Dialog. So close, yet so far…More to follow soon, till then happy UI-Scripting!
Ravindra R Upadhya
My goal is to share my love and knowledge of Microsoft Dynamics software. If you want fluff-free stories about software with legs, you've come to the right place.
DynamicsTips.com is the place to get the latest news and technical tips on Microsoft Dynamics products, whether you're a developer or a user.