Populate Two Options values when creating a record in a dialog

Scenario:

“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.”

image

“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.”

image

image

Custom workflow activities to the rescue!  I wrote a very simple workflow activity that converts the integer to a boolean.

image

image

image

Once you have the ‘Two Options’ typed value, you can map it to your field.

image

The code for the workflow activity is the simplest workflow activity I have ever created:

image

If you don’t want to build/deploy the code yourself, but just want to use the workflow activity to solve this problem, then you can download an unmanaged solution here:

https://skydrive.live.com/redir?resid=1F72DA7294089597!16571

I also have an end to end example in an unmanaged solution here:

https://skydrive.live.com/redir?resid=1F72DA7294089597!16570

In the end to end example, I went ahead and created a ribbon button that will launch the dialog without having to select an entity in the grid.

image

I used the User entity trick from http://dkdt.me/KmqxOZ.  In putting together the sample, I was also inspired by http://dkdt.me/KmqwdV.  However, I took a shortcut.  I hard coded the CRM User guid for the ObjectId in the dkdt_/scripts/LaunchModalDialog.js file.  You will need to go into it and update it with an actual user in your CRM org for the sample to work.

If you want the source code for everything, you can grab it here:

https://skydrive.live.com/redir?resid=1F72DA7294089597!16569

NOTE: The code requires the Developer Toolkit for Microsoft Dynamics CRM 2011.

 

@devkeydet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s