Just like we had the ability to extend CRM using plugins and workflows, we now have the option of Dialogs as well.
What is different in Dialog?
Dialog runs synchronously like the Plugins but they have the option of providing user interface to accept custom information required for processing.
I took an example of a situation where, you want to add custom logic that will do the following if the user tries to make an Account inactive.
- Check if it has a parent account associated with it, if so let the user know about it
- Confirm if they want to de-activate the parent account as well.
- If yes go ahead and de-activate it
- Check if the account has Child accounts associated with it, if so let the user know
- Disable the Child accounts as well if the users wants.
Dialogs let you design a wizard like user interface for user input. In this example we have tried to use all the features that the dialog offers. The aim here is to demonstrate the various features of Dialogs.
Check if it has a parent account associated with it, if so let the user know about it
This can be done through the if condition that was available within workflows as well.
Confirm if they want to de-activate the parent account as well.
Here we shall make you of the Page feature that has been added within dialogs. We shall design a user interface that will ask the user the question and get the Yes/No response back.
For response we have set the type to be Option Set (Radio button). We have defined the values as Yes and No.
This page is then called from the Dialog as the next step
If yes go ahead and de-activate it
We can check the user response to our question in the earlier step and based on that proceed further. Here we have called another Child workflow that is designed to de-activate the account passed to it. The parameter can be passed by selecting the attribute of the Account entity on which the workflow needs to be executed.
Check if the account has Child accounts associated with it, if so let the user know
We need to design a query that will let you search for child accounts.
Here is the trick to designing a parameterized query. When designing the query, user the like condition and specify a dummy name in the query as shown below
There after switch to the Define fetch XML query text tab.
Change the query value to Variable1%. Once you write that, you have the Variable1 showing up on the XML values section. There select the Account Name attribute of the account entity.
This will now search for accounts where parent account = current account.
To see if the query returned results, use the following condition
Disable the Child accounts as well if the users wants
The dialogs do not allow us to loop through the query results and perform action on each of the record found. But it supports calling of Workflows. So the last step is performed by making a call to a workflow assembly.
You can pass the responses received from the user on a page designed in the dialog to the Custom Workflow Assembly.
Dialogs are fun and if put to correct use, it is a very strong tool that has been provided to us.