Often we come across requirements where a user wants to perform certain actions in a loop. However, there is no direct way to achieve this feature either with workflows or dialogs. In this post we are going to discuss how we can achieve this using Dialogs in Dynamics CRM.
In this article I will be introducing the concept of invoking dialog in a loop rather than explain with an example. Also this article does not talk about how to create dialogs or how they work in Dynamics CRM.
Create a Dialog, let’s call it “Child dialog” against Account entity as a child process. Keeping the logic in dialog to minimum, call the same dialog based on user response. Normal logic can be added based on the requirements.
There is no restriction on adding variables or input parameters or other steps in this process. Adding a prompt will allow system not to go into infinite look. This is an important step.
Also, conditional check in the screen shot is on response value which is an integer value, this can be changed based on requirements.
Step 2: Activate the child dialog.
This step is required to trigger the child dialog for an entity form.
Create another dialog and call it as “Master Dialog” against Account entity as an on-demand process.
Again, we can add any variables, input parameters or other steps to this process without any restriction.
Invoke the child dialog activated in step 2.
Step 4: Activate the Master dialog.
When you invoke Master dialog from Account entity, the output will something like this.
On selecting “Yes” Master dialog invokes child dialog.
Till user selects “No” in this dialog, the loop continues and invokes the child dialog.
It’s simple and powerful steps which can be explored in other practical scenarios. One scenario where I can see use of recursive dialogs is for a call center in healthcare where a call center user need to request and log pre-existing multiple health symptoms.