Is is an excellent read, and shows the power and ease of using custom workflows. I am going to provide a solution for the same scenario which uses the existing process (workflow) UI, but without any custom coding.
The business case is pretty straightforward. Here is the scenario from the blog post in its entirety:
“I have an entity with a field of type ‘Two Options’ that I would like to populate within a ‘Create Record’ activity in a CRM 2011 dialog. The ‘Two Options’ type in CRM 2011 is a boolean. The ‘Prompt and Response’ activity in a CRM 2011 dialog only gives me options for Text/Integer/Float. Because of this, I can’t set the value of the answer to the field in the entity within ‘Set Properties’ because the types don’t match.”
Here are the steps to achieve the same result without the custom code workflow:
1. Create a new placeholder text field in the entity. I have added it to the form for testing purposes, but you can either remove it or make the field not visible.
2. Create a dialog which is pretty identical to the example I am trying to imitate: One page for the name, and one page for the Yes/ No radio button.
3. At the end, create a new record, with the Yes/ No value from step 2 being mapped to the placeholder field in the entity.
4. Create a new workflow for the custom entity, which triggers when the record is created.
5. Add a check condition to evaluate the placeholder value. If value = "Yes", update the current record two option value to "Yes".
Kick off the dialog and test it out. You will see that the option value is set based on the selection from the dialog page.
Bonus Read:
Another option is to have the placeholder field like before, and set the value of the boolean with javascript. The idea is to read the value of the placeholder field during onload(), and then set the value either "Yes" or "No". I would not recommend it though, for the following 2 reasons:
a) The value is set only if the user opens up the form. If there is no manual intervention, the option value stays incorrect. Not good news for your views and reports!
b) The user, even after opening the record, could close out the form without saving changes. You are back to messed up views and reports that use incorrect data.
Final Thoughts:
I think the post by @devkeydet is the most elegant solution of them all. But if your options are limited with respect to resources, using the placeholder and workflow UI could be an option.
No comments:
Post a Comment