<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Richard Knudson&#039;s Dynamics CRM Trick Bag &#187; Dynamics CRM Workflows</title>
	<atom:link href="http://www.dynamicscrmtrickbag.com/category/workflow/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dynamicscrmtrickbag.com</link>
	<description>Building business value on Dynamics CRM</description>
	<lastBuildDate>Fri, 27 Jan 2012 14:42:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Profile and Survey Customers with CRM 2011 Dialog Processes</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/12/31/profile-and-survey-customers-with-crm-2011-dialog-processes/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/12/31/profile-and-survey-customers-with-crm-2011-dialog-processes/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 20:34:16 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/12/31/profile-and-survey-customers-with-crm-2011-dialog-processes/</guid>
		<description><![CDATA[December 31, 2011 - One of the most obvious applications of dialog processes are scripted conversations. And one of the most obvious examples of a scripted conversation is a survey. Dialog processes work great for all kinds of surveying and profiling requirements, and that's what this special New Year's Eve edition of the Dynamics CRM Trick Bag is all about. And for the record, without intending any disrespect to the Mayans, I think 2012 is going to be an excellent 365-day year!]]></description>
			<content:encoded><![CDATA[<div>One of the most obvious applications of dialog processes are scripted conversations. And one of the most obvious examples of a scripted conversation is a survey. Dialog processes work great for all kinds of surveying and profiling requirements, and we&#8217;ll review an example of that here. But first, let&#8217;s review our choice of tools: there are lots of ways to conduct surveys, and it&#8217;s reasonable to ask why you might consider using a Dynamics CRM dialog process for one rather than say, Survey Monkey (<a href="http://www.surveymonkey.com/">http://www.surveymonkey.com/</a>).</div>
<div>Here are some of the factors that would make the Dynamics CRM approach appropriate for a job like this:</div>
<ul>
<li>If the people you want to survey are in your CRM (e.g., as contacts), taking a CRM-centric approach is compelling. This is the same argument as using a CRM add-on solution for email marketing rather than, say Constant Contact: survey results might be as important a piece of customer history as email click-throughs, so it&#8217;s natural to want them in your CRM.</li>
<li>The kind of surveying and profiling described next can be done with the out-of-the-box CRM feature set plus a few customizations, so you won&#8217;t pay additional licensing fees or have to learn a new application.</li>
</ul>
<div>Why might you <em>not</em> want to use Dynamics CRM dialog processes for surveys?</div>
<ul>
<li>Complex survey functionality will be more easily implemented with a dedicated survey application. As you&#8217;ll see, using Dynamics CRM for a job like this one is a bit of a DIY project, and as with all DIY projects, you&#8217;re essentially making a<em> build v. buy</em> decision.</li>
<li>Dialog processes must be run by a licensed CRM user. So if you need to provide a self-service survey option, the CRM-centric approach discussed here won&#8217;t be an option.</li>
</ul>
<ol>
<li>
<h4>Profiling and Surveying Customers: The Goal</h4>
<div>This approach I&#8217;ll describe here requires some customizations, and there are many different ways of implementing it: from simple and specific, to complex and flexible. Let&#8217;s start by examining how this surveying solution works, so you know what we&#8217;re shooting for.</div>
<div>Some organizations have highly structured &#8220;onboarding&#8221; process to be applied when new customers are signed up. For example, a bank might have a standard set of questions to ask of new savings account customers, or a marketing department might want to know if a new customer was influenced by any of its ads, mailings and so forth. Other common requirements of onboarding processes like these are to get feedback from the customer on their overall satisfaction level and to confirm that important information on the customer record is correct.</div>
<div>The following figure shows the single page of our dialog process as it&#8217;s being run by a user. This process is written for the contact entity, and you can see in the first (highlighted) prompt that we&#8217;re using dynamic values to provide the user with a customized script (<strong><em>Hello, Eva</em></strong>) and to call attention to some of the most important contact information we want our user to verify or correct.</div>
<div>Notice also that in the Tip section we&#8217;ve provided a link (<span style="color: #4f81bd; text-decoration: underline;"><strong>Navigate to contact record</strong></span>) and instructed the user to go directly to the contact form if they need to make any changes:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS1.png" alt="" /></div>
<div>The next figure highlights the <strong>How did you hear about us</strong> option set. You&#8217;ll see below that we used a custom entity to store these values, and a query in the dialog process to present them to the user.</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS2.png" alt="" /></div>
<div>The following figure presents the &#8220;rate your overall experience on a 1-5 scale&#8221; question.</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS3.png" alt="" /></div>
<div>After the user clicks the Finish button, the process creates three records for a custom entity,<strong> Survey Response</strong>, one for each of the questions. (It might look like there are four, but remember the first one is just a prompt, with no response being captured.)</div>
<div>The following figure illustrates that the Survey Response entity has an N:1 relationship to contact, so our design requirement of having survey responses be part of the comprehensive customer history is satisfied:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS4.png" alt="" /></div>
<div>Here&#8217;s the data grid for survey responses with the All Survey Responses view selected. Notice that I&#8217;ve added several different fields to store different kinds of responses. This is an important detail and I&#8217;ll describe it more fully below.</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS5.png" alt="" /></div>
<div>Finally, the following figure really starts to highlight some of the potential benefits of this approach. A custom view filters survey response records to only include records for the Experience Rating question. This means that a custom chart can be used to visualize the results:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS6.png" alt="" /></div>
<div>Here, the chart is constructed with the average value of the <strong>Response (Decimal)</strong> field as the <strong>Series</strong>, and the data are distributed across the owners of the underlying contact records.</div>
</li>
<li>
<h4>Setting Up</h4>
<div>I used three custom entities to implement this solution: Survey, Survey Response, and Lead Source. The following Visio diagram illustrates how they&#8217;re related to each other and to Contact:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS7.png" alt="" /></div>
<div>Contact and Survey both have 1:N relationships to Survey Response, effectively creating an N:N between Contact and Survey. Notice that Lead Source isn&#8217;t related to anything. Of course, it could be related to other entities, but for this example it is not required to be. As you&#8217;ll see below, the only role the Lead Source plays here is to allow us to query the values so we don&#8217;t have to enter them in the dialog designer!</div>
<div>
<table border="0" style="border-collapse:collapse">
<colgroup>
<col style="width: 143px;"></col>
<col style="width: 143px;"></col>
<col style="width: 353px;"></col>
</colgroup>
<tbody>
<tr style="background: #4f81bd">
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2">
<div><span style="color:white"><strong>Entity</strong></span></div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><span style="color:white"><strong>Custom Fields</strong></span></div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><span style="color:white"><strong>Field Type and Purpose</strong></span></div>
</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2" rowspan="2">
<div><span style="color:white"><strong>Survey<br />
</strong></span></div>
</td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Survey Name</div>
</td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Single Line of Text.</strong></div>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Survey Date</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Date and Time.</strong></div>
</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2" rowspan="7">
<div><span style="color:white"><strong>Survey Response</strong></span></div>
</td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Name</div>
</td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Single Line of Text. </strong>Auto-filled by workflow.</div>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Question</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Single Line of Text. </strong></div>
</td>
</tr>
<tr style="background: #d8d8d8">
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Respondent</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Lookup to Contact entity</strong>.</div>
<div>Creates a custom 1:N relationship from Contact to Survey Response</div>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Survey</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Lookup to Survey entity.<br />
</strong></div>
<div>Creates a custom 1:N from Survey to Survey Response.</div>
</td>
</tr>
<tr style="background: #d8d8d8">
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Response (Whole Number)</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Whole Number</strong>.</div>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Response (Decimal)</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Decimal Number</strong>. This is important for reporting and charting, and is the appropriate field type for most numeric survey responses.</div>
</td>
</tr>
<tr style="background: #d8d8d8">
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Response (Short Text)</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Single Line of Text.</strong></div>
</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2">
<div><span style="color:white"><strong>Lead Source</strong></span></div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div>Lead Source Name</div>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">
<div><strong>Single Line of Text.</strong></div>
</td>
</tr>
</tbody>
</table>
</div>
<div>After creating and publishing these customizations, customize the security role of any user that will be conducting surveys. This is an important step: it&#8217;s easy to forget, and if you don&#8217;t do it the dialog process will not work! The way I&#8217;ve written the dialog process, it creates the survey responses and assigns them to the owner of the contact providing the responses. Survey Response is a custom entity, and by default no security roles except System Administrator have privileges to custom entities. The following figure shows the minimum privileges required for this to work (user-level read privilege for the Survey Response entity), assuming a participating user has the Salesperson security role:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS8.png" alt="" /></div>
</li>
<li>
<h4>How it Works</h4>
<div>The dialog process is written for the Contact entity, and is only available to run on-demand. To make it easier to understand I built it with three stages, shown collapsed in the process designer here:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS9.png" alt="" /></div>
<div><strong>Stage 1</strong> only does one thing: uses <strong>Query CRM Data</strong> to build a static query for Lead Sources:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS10.png" alt="" /></div>
<div><strong>Stage 2</strong> contains the dialog&#8217;s single page, with four <strong>Prompt and Response</strong> pairs:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS11.png" alt="" /></div>
<div>The first Prompt and Response is actually a prompt with no response:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS12.png" alt="" /></div>
<div>Note the use of dynamic values in the prompt, to both personalize the conversation and display some of the most important fields from the contact record. Also of interest is the use of the dynamic record URL in the tip text. This important functionality was first introduced in the November 2011 Service Update and it allows you to dynamically generate a link so the user can easily open a record&#8217;s form from the context of the dialog process.</div>
<div>The <strong>Insert Hyperlink <img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS13.png" alt="" /></strong> icon is available both for Prompt Text and Tip Text. The following figure illustrates how I constructed the link for this example, which I then combined with static text to provide complete instructions to the user:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS14.png" alt="" /></div>
<div>The next figure shows the Prompt and Response properties for the Source. Rather than entering the values within the dialog designer, I queries the Lead Source custom entity.</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS15.png" alt="" /></div>
<div>If you wondered before why I took that approach, now you can probably appreciate the design decision. Even though it took a little work to set it up, here are the three main reasons I chose this approach in the present example:</div>
</li>
</ol>
<ul style="margin-left: 38pt">
<li>It&#8217;s much easier for a user to maintain Lead Source values as an entity than it is to customize the dialog process itself.</li>
<li>Something like <strong>Lead Source is</strong> a good candidate for re-use across different entities. For example, there&#8217;s an option set field with the same name available on the lead entity in CRM. I generally prefer the custom entity approach over the option set approach, and keeping track of lead sources is a pretty common requirement.  So even if my only <em>current</em> requirement for a lead source lookup is within this dialog process, chances are good another one will come along later, and I&#8217;ll be ready when it does.</li>
<li>It&#8217;s time-consuming and tedious to enter hard-wired values in the process designer in the first place!</li>
</ul>
<div>The next figure shows the actual survey question. This is handled with a simple option set, and this time I used the Define Values option. The most important thing here is the make sure you select the Integer data type as I&#8217;ve done, so you can place the response into a numeric field in the survey response record:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS16.png" alt="" /></div>
<div>So it&#8217;s on to Stage 3, which I usually refer to as the post-dialog processing stage. Stage 3 has four steps, each one a Create Record step. The first three create the survey response records, each associated with the contact providing the responses, and the fourth creates an e-mail:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS17.png" alt="" /></div>
<div>The three <strong>Create Survey Response</strong> steps are similar; the following figure shows the properties for the Experience Rating response:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS18.png" alt="" /></div>
<div>Dynamic values are combined with static text to fill in the Name field. The record is associated with the contact with dynamic values on the Respondent field. The Question field is filled with static text, and it&#8217;s important to note here that I&#8217;m placing the response value into the custom Response (Decimal) field. Also, notice the survey response record is associated with the actual survey with a hardwired selection in the Survey lookup field.</div>
<div>Finally, the <strong>Create E-mail</strong> step properties are shown in the following figure:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS19.png" alt="" /></div>
<div>I&#8217;m sending this to the owner of the contact record, but you could easily imagine sending a summary to the contact as well, and that would work fine. Dynamic values are used in the Regarding field to attach the email activity as part of the contact history, and note the use again of the <strong>Insert Hyperlink/Record URL(Dynamic)</strong> combo. That&#8217;s quickly become one of my most frequently used features in workflow and dialog processes.</div>
<ol>
<li>
<h4>Reporting, Charting, Extensions and a Few Tips &amp; Tricks</h4>
<div>This example raises a number of interesting issues and there are several different design decisions you might consider. I&#8217;ll review a few of those here.</div>
</li>
</ol>
<ul>
<li>
<div>I mentioned a couple of times <strong>the importance of using the Decimal Number data type</strong> for the experience rating response in this example. You might think that the Whole Number data type would work just as well, and in fact, I&#8217;ve (mistakenly) taken that approach at least twice now. Why would it be a mistake for this solution?  To understand this, consider again the chart I showed above:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS20.png" alt="" /></div>
<div>Notice that the average values displayed on the chart include two decimal places. If instead of placing the experience rating response into a Decimal Number field I&#8217;d placed it into a Whole Number field, the charting engine would display every data point with no decimal places, rounding it up or down to the nearest whole number! It&#8217;s not clear to me why the charting engine does this, but it does, so be sure to use the Decimal Number field type if you want to use the built-in charting and dashboarding features in CRM for applications like this.</div>
</li>
<li>
<div>Another data type anomaly lurks in this example as well: <strong>the difference between the Single Line of Text and the Multiple Lines of Text field types.</strong> Remember that in the approach I took, the source response was placed into a Single Line of Text field. That allows me to create a chart that shows how contacts are distributed across Lead Sources, like this:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS21.png" alt="" /></div>
<div>To create a chart like this, you first need an appropriate view to filter down to the right question type, and then you can create the chart in the Chart Designer, like this:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS22.png" alt="" /></div>
<div>The first time I tried this I stored a response to a <strong>Multiple Lines of Text</strong> field, and in the chart designer I couldn&#8217;t use it as the Category field: it just doesn&#8217;t show up. So, just remember: if you want to see counts of how records in a view are distributed across various values of a text field, make sure it&#8217;s a Single Line of Text field.</div>
</li>
<li>
<div><strong>Possible extensions</strong>. Remember how I used Query CRM Data so I wouldn&#8217;t have to enter the Lead Source values manually in the process designer?  And remember how in the experience rating prompt/response step I entered them manually? Well, suppose you needed to create a survey with several separate rating type questions, and suppose further that they were all on a 1-9 scale. (I once owned a training company and for years we gave students post-class evaluations on 9-point scales to rate things like the instructor&#8217;s subject matter expertise, courseware quality, facility quality and the overall value of the learning experience, so I know for a fact people perform surveys like that.) Anyway, manually entering the first set of nine values might not seem so bad, but as you entered the second set you&#8217;d probably wonder if there was a better way. And by the time you got to the third set you&#8217;d be tempted to just go with a paper-based process instead!</div>
<div>If you do have surveys that require multiple questions of the same type (the same rating scale, for example), there are better approaches you can take. For example, consider the following figure:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS23.png" alt="" /></div>
<div>This is a custom entity – <strong>Possible Survey Responses</strong> – with two fields: Response Type is an option set, with values such as <em>Three point scale</em>, <em>Five point scale</em> and so forth. There&#8217;s a single record for each possible response for the response type, with an appropriate value in the response value field. You can then take advantage of a custom entity like this in the dialog design process, querying the entity for the possible response values for each response type, as the following figures illustrate.</div>
<div>Suppose you start by building queries for the different kinds of survey questions a survey has:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS24.png" alt="" /></div>
<div>Each query is simple. The next figure shows the properties of the <strong>Five point scale</strong> query, which simply filters on the Response Type option set:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS25.png" alt="" /></div>
<div>Once you&#8217;ve done that, you&#8217;re all set for the Prompt and Response steps, since you can get the option set values directly from the queries, rather than entering them manually:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/123111_2032_ProfileandS26.png" alt="" /></div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/12/31/profile-and-survey-customers-with-crm-2011-dialog-processes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking and Scoring User Activity</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/12/13/tracking-and-scoring-user-activity/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/12/13/tracking-and-scoring-user-activity/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 00:30:35 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/12/13/tracking-and-scoring-user-activity/</guid>
		<description><![CDATA[December 14, 2011 - Everybody agrees that user adoption is a good thing, and that high user adoption is a key measure of the overall success of a CRM implementation. But how can you measure "user adoption?" This article describes a simple approach, combining a couple of customizations and a few workflows, to come up with a single metric by which users can be ranked. And for best results, don't tell your users you're measuring their activity!]]></description>
			<content:encoded><![CDATA[<div>Everybody agrees that user adoption is a good thing, and that high user adoption is a key measure of the overall success of a CRM implementation. But there&#8217;s less agreement on how to <em>measure</em> user adoption. One way is to use a dashboard to directly display measures of &#8220;what users are doing&#8221;. For example, suppose you&#8217;re interested in tracking how many records are created, over time and by user, for several key record types, such as accounts, contacts, and opportunities, and examine the following figure:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand1.png" alt="" /></div>
<div>This dashboard displays a set of time series charts in the first row, of total records created over the last six months for accounts, contacts and opportunities. In the second row, a corresponding chart for each record type shows the distribution of the same records across their owning users.</div>
<div>Dashboards like this can of course be created for any record type – activities, cases, leads, custom entities – and can provide a good high level view of &#8220;who&#8217;s doing what.&#8221; But although visualizations like this are a good start, they don&#8217;t go far enough in several ways. For example:</div>
<ul>
<li>They provide visualization, but they don&#8217;t really provide a <em>measure</em>.</li>
<li>They don&#8217;t scale very well. For example, if you need to measure and compare usage for dozens or more users, they won&#8217;t be very effective.</li>
</ul>
<div>However, you could <em>score</em> various user activities, assigning a certain number of points for different kinds of activities. For example, consider the following table:</div>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup>
<col style="width: 217px;"></col>
<col style="width: 132px;"></col>
</colgroup>
<tbody>
<tr style="background: #4f81bd">
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Activity</strong></span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Score</strong></span></td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">Completed Appointment</span></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">2</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">Completed Phone Call</span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">2</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">New Contact </span></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">5</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">New Account</span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">5</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">New Opportunity</span></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">5</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">Won Opportunity</span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">10</td>
</tr>
</tbody>
</table>
</div>
<div>Obviously the scheme you use to score users&#8217; activities will differ for every business, but something like this one accords with common business requirements as well as with the way Dynamics CRM is intended to be used:</div>
<ul>
<li>For activity records, it&#8217;s completed ones that matter. Canceled ones don&#8217;t count.</li>
<li>Contacts and accounts – the customer records – are worth more than a completed activity.</li>
<li>And while opportunities are worth something to create, they&#8217;re worth even more to close as won!</li>
</ul>
<div>Tracking and scoring user activity can be accomplished by combining several customizations and workflows, and an example of this is presented next. The end-goal is a dashboard like the one in the following figure:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand2.png" alt="" /></div>
<div>The key concept is that a single all-up score is tracked for each user. This is displayed in the <strong>Activity Score Leaders</strong> chart in the top row. The first two charts in the top row break out users&#8217; scores by activity type, for different time periods: today and the last 30 days. The grid shown underneath the charts is a custom entity, here playing the role of a reminder to users, so they know how different activities are scored.</div>
<h2>Setting Up</h2>
<div>There are two main customizations required for the user activity scoring approach described here:</div>
<ul>
<li>A single custom field is added to the user entity to maintain an all-up &#8220;total score&#8221; value.</li>
<li>And because it might be important to report on a user&#8217;s score over different time periods, I use a custom entity – Activity Counter Records – to store the detail on every activity contributing to the overall score.</li>
</ul>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup>
<col style="width: 142px;"></col>
<col style="width: 142px;"></col>
<col style="width: 354px;"></col>
</colgroup>
<tbody>
<tr style="background: #4f81bd">
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Entity</strong></span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Custom Fields</strong></span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Field Type and Purpose</strong></span></td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" rowspan="4"><span style="color:white"><strong>Activity Counter (custom)</strong></span></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Name</td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Single Line of Text.</strong> Name of record</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Record Type</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Single Line of Text</strong>. Account, contact, appointment, etc.</td>
</tr>
<tr style="background: #d8d8d8">
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Event</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Single Line of Text</strong>. Create, Complete, Won, etc.</p>
<div>Creates a custom 1:N relationship from User to SLA</div>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Score</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Whole Number</strong>. Tracks score for each activity</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">User</td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Lookup to User. </strong>Associates each record with the user performing the activity. You can use the system Owner field for this, or create a custom lookup field. In the approach described here a custom lookup field is used.</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>User</strong></span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Activity Counter Aggregate Score</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Whole Number.</strong> This field stores the all-up &#8220;aggregate&#8221; score for each user.</td>
</tr>
</tbody>
</table>
</div>
<h2>How it Works</h2>
<div>To focus on the essentials, let&#8217;s implement a simple version of user activity scoring according to these rules:</div>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup>
<col style="width: 217px;"></col>
<col style="width: 132px;"></col>
</colgroup>
<tbody>
<tr style="background: #4f81bd">
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Activity</strong></span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Score</strong></span></td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">Completed Appointment</span></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">2</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">New Contact </span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">5</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">New Opportunity</span></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">5</td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white">Won Opportunity</span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">10</td>
</tr>
</tbody>
</table>
</div>
<div>One workflow will be used for each of these activities, and it will perform the following actions:</div>
<ul>
<li>Create an activity counter record with the appropriate values, and associate it with the user performing the activity being scored.</li>
<li>Update the aggregate score field on the user&#8217;s record.</li>
</ul>
<div>Here are the four workflows as they appear in the process grid:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand3.png" alt="" /></div>
<div>The following three figures illustrate the workflow that performs the scoring for the completed appointment activity. First, the following figure shows the workflow properties and overall structure:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand4.png" alt="" /></div>
<div>It&#8217;s triggered by <strong>Record status changes</strong>, and the first <strong>If</strong> condition checks the status, only proceeding if the appointment is completed. I wrote this to also perform a check on whether the <strong>Regarding</strong> field contains data. This illustrates a possible requirement that only certain kinds of appointments get scored, such as those associated with account or contact records, etc.</div>
<div>The first action performed by the workflow is to create an activity counter record:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand5.png" alt="" /></div>
<div>The most important point to note here is that the only way an activity counter record gets created is via these workflows. So in this approach, every (or almost every) field will get filled in automatically, behind the scenes. Records like these are not intended to be created interactively by a user! This accounts for why we can use simple text fields for things like <strong>Record Type</strong> and <strong>Event</strong>: since they&#8217;re always filled by the workflow, they&#8217;ll always be entered correctly.</div>
<div>Also, notice that the <strong>Score</strong> field is simply set to a fixed value, in this case 2.</div>
<div>The activity counter record is associated with the user with dynamic values on the custom User lookup field. In this example I filled both the <strong>Owner</strong> and custom <strong>User</strong> field, although that&#8217;s not really required.</div>
<div>The next step is to update the aggregate score field on the user record:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand6.png" alt="" /></div>
<div>Here, the most important difference is the use of the <strong>Increment by</strong> operator: that&#8217;s how we get a convenient single all-up activity score stored on the user record.</div>
<div>The logic of the other three workflows is essentially the same. Here are a few things to think about and variations you might try:</div>
<ul>
<li>
<div>If all you need to do is track an aggregate score for each user, you don&#8217;t need the custom entity I used (activity counter). But remember, if you don&#8217;t have that you lose the time dimension along with activity details. For example, the following figure shows a specific user&#8217;s activity counter records from the context of the user form, one of which you&#8217;d have without the custom entity:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand7.png" alt="" /></div>
</li>
<li>
<div>Notice that the scoring logic in this approach is embedded in the workflow processes. In that sense it&#8217;s a little bit &#8220;hardwired&#8221;. With a little more work, you could create the ability for a user to configure settings for scoring, so that if you needed to change the score a user receives for an activity, you could update a record rather than the workflow process itself. One way to do this would be to create another custom entity, such as <strong>Activity Counter Settings</strong>, and have each activity counter record be a child record of a specific settings record. If you take another look at the way I created the activity counter record you&#8217;ll see a clue about how this approach can work:</div>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121411_0029_Trackingand8.png" alt="" /></div>
<div>The <strong>Counter Setting</strong> field is a lookup, which if filled in will associate a counter record with a parent setting record. If you took this approach, then the Score field could be filled with dynamic values rather than directly as in this approach.</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/12/13/tracking-and-scoring-user-activity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Round-Robin Record Assignment with CRM 2011 Dialog Processes</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/12/11/round-robin-record-assignment-with-crm-2011-dialog-processes/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/12/11/round-robin-record-assignment-with-crm-2011-dialog-processes/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 19:26:13 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/12/11/round-robin-record-assignment-with-crm-2011-dialog-processes/</guid>
		<description><![CDATA[December 12, 2011 - The Dynamics CRM literature is replete with articles about round-robin schemes to assign records. It turns out to be easier to implement processes like this with dialogs than with workflows, because a dialog process can extend its data context as it runs. Here's an example. Enjoy!]]></description>
			<content:encoded><![CDATA[<h2>Round-Robin Processes</h2>
<p>There are many flavors of round-robin record assignment processes, but they all share some fundamental properties. The most important is that they all implement what you might refer to as an &#8220;egalitarian&#8221; record assignment process. For example, records are assigned first to sales rep 1, then to sales rep 2, and so on until sales rep N gets her assignment, then the process starts over again with sales rep 1 next in line.</p>
<p>We&#8217;ll examine a dialog process version of this here, but since we&#8217;re on the topic it might be worth characterizing several different assignment processes, all of which could be implemented with workflows or dialogs in Dynamics CRM:</p>
<ul>
<li>If you create an opportunity record, you own it. Call this the &#8220;chew your own meat&#8221; school of record assignment.</li>
<li>If an opportunity is created for a customer you own, you get the opportunity. This is the strong version of the owned-account school of record assignment.</li>
<li>If an opportunity is created for an industry or product in which you have expertise, it gets assigned to you. Call this the strong version of the industry expertise school.</li>
</ul>
<p>Many organizations combine several different styles of record assignment, within or across business units. For example, you might use a strong owned-account assignment approach for opportunities created for owned accounts, but have a set of accounts designated as &#8220;house accounts&#8221;, and assign opportunities for those accounts on a round-robin basis.</p>
<p>Or if you&#8217;re a mortgage banker, you might assign loan modifications on a round-robin basis. Since load modifications don&#8217;t have new money associated with them, you might put them in the take-one-for-the-team category and distribute them equally to a pool of loan modification processers.</p>
<h2>Workflows v. Dialogs for Round-Robin Assignment</h2>
<p>Remember our <a href="http://www.dynamicscrmtrickbag.com/2011/11/30/crm-2011-dialogs-should-you-use-query-crm-data-or-lookup/">discussion comparing the data context of workflow and dialog processes</a>. One implication of that discussion is that round-robin processes are much easier to implement with dialog processes than with workflows. This is because a running instance of a workflow doesn&#8217;t have any way of knowing anything about other instances, and thus doesn&#8217;t know anything about previous record assignments. The standard way of getting around this in a workflow is to create a custom entity that functions as the parent record of every opportunity needing to be assigned. (For example, Ben Vollmer wrote the first <a href="http://blogs.msdn.com/b/crm/archive/2009/02/10/microsoft-dynamics-crm-round-robin-lead-assignment.aspx">article on this topic</a>.)</p>
<p>The workflow can then both query the parent record for things like which user got the last assignment, as well as update it with who&#8217;s getting the current assignment. As you will see here, this kind of workaround in unnecessary for dialogs, since they can create their own data context as they run.</p>
<p>The scenario for this example is as follows:</p>
<ol>
<li>A user selects a specific opportunity record and starts the dialog process.</li>
<li>The dialog builds a query of &#8220;participating users&#8221;: that is, users designated as participating in the round-robin process.</li>
<li>The query will be in ascending date order by the date each participating user was last assigned an opportunity by the process.</li>
<li>The user will be instructed to select the user at the top of the list, but can depart from the &#8220;last-in first-out&#8221; rule if necessary.</li>
<li>After the user is selected, the dialog assigns the record and performs some other data updates.</li>
</ol>
<h2>Setting Up</h2>
<p>This dialog requires customizations to the User entity: a check-box field to specify participating users, and a date field to keep track of the last assignment date:</p>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup>
<col style="width: 140px;"></col>
<col style="width: 145px;"></col>
<col style="width: 353px;"></col>
</colgroup>
<tbody>
<tr style="background: #4f81bd">
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2"><span style="color:white"><strong>Entity</strong></span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Customizations</strong></span></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Field Type and Purpose</strong></span></td>
</tr>
<tr>
<td style="background: #4f81bd; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2" rowspan="2"><span style="color:white"><strong>User</strong></span></td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Field: Participates in Round-Robin Process</td>
<td style="background: #d8d8d8; padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Two Options.</strong> Specifies a user&#8217;s participation in process.</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Field: Last Assignment Date</td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><strong>Date and Time</strong>. Date of last assignment as part of process.</td>
</tr>
</tbody>
</table>
</div>
<p>The following figure shows how these fields could be placed on a user form:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121111_1925_RoundRobinR1.png" alt="" /></p>
<p>Of course in a production environment you don&#8217;t want any old user going in and changing these things, so you&#8217;d need to come up with an approach for making sure that the only users who can change them are the ones that are supposed to be able to.</p>
<h2>How it Works</h2>
<p>For this example, let&#8217;s start by examining the user experience. To keep it simple, I&#8217;ll start from the opportunity data grid, but in a production environment you might start from a queue for unassigned opportunities, and lock down the queue so that only certain users can kick off the process. The following figure shows how it looks as a user runs the process: a single opportunity record is selected on the grid, and the dialog prompts to select the user to whom the record should be assigned:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121111_1925_RoundRobinR2.png" alt="" /></p>
<p>The two most important things to notice about this are as follows:</p>
<ul>
<li>Only a subset of users are available for selection. You&#8217;ll see how the query uses the <strong>Participates in Round Robin Process</strong> field to filter out non-participating user records.</li>
<li>The list of participating users is presented in ascending order by the <strong>Last Assignment Date </strong>field. Essentially, this prompts the user to apply the last-in-first-out logic, but allows for out of order selection. The user is instructed to provide an explanation for any out of order assignments in the text field.</li>
</ul>
<p>Suppose I finish that dialog by selecting User A. The selected opportunity is removed from the My Opportunities view (unless I happen to be User A!) because the dialog process assigns it to that user. Now if I run it again, the experience is slightly different:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121111_1925_RoundRobinR3.png" alt="" /></p>
<p>Now User B percolates to the top of the list. As you&#8217;ll see next, this is because the dialog process updates the Last Assignment Date field so you&#8217;ll always have the ability to sort by that field.</p>
<ol>
<li>
<h4>Building the Dialog Process</h4>
<p>The dialog itself (name) is created for the Opportunity entity, and is available to run only on demand. The following figure shows the step editor for the dialog process. I&#8217;ve used stages to organize the process in the designer, in what is a very common configuration for a dialog process that uses a query:</p>
<ol>
<li><strong>Query.</strong> This stage contains the single Query step.</li>
<li><strong>Dialog UI.</strong> This stage presents the user experience; the first prompt uses the query to present the the list of participating users.</li>
<li><strong>Post-dialog Processing</strong>. After the user clicks Finish, the steps in this stage create records, assign them, update them as necessary and so forth.</li>
</ol>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121111_1925_RoundRobinR4.png" alt="" /></p>
<p>The next figure shows how to construct the Participating Users query. The single filter condition uses the custom field added to the user entity (<strong>Participates in Round Robin Process</strong>). To sort the query in ascending order by <strong>Last Assignment Date</strong>, click the Edit Columns button:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121111_1925_RoundRobinR5.png" alt="" /></p>
<p>The next figure shows how to construct the Prompt and Response using this query. I used the <strong>Prompt Text</strong> to instruct the user on what to do for out of order assignments, but if my advice got much longer than this, I&#8217;d probably use the <strong>Tip Text</strong> to give it a cleaner look. Also, notice how I constructed the Separator, using a semi-colon and some static text to make it more obvious what the date field refers to:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121111_1925_RoundRobinR6.png" alt="" /></p>
<p>The first step in stage 3 is pretty obvious: it assigns the selected record to the selected user. The second step is more interesting. This updates the <strong>Last Assignment Date</strong> field on the user record with the current time, so that next time you run the process the user with the most recent assignment goes to the bottom of the list:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/12/121111_1925_RoundRobinR7.png" alt="" /></p>
<p>Some time ago I made a video on this kind of a dialog process. You can see it, along with a few others, on the <a href="http://www.dynamicscrmtrickbag.com/trick-bag-video/">Trick Bag Video page</a>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/12/11/round-robin-record-assignment-with-crm-2011-dialog-processes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dialog Power Tips: Run a Dialog from a Dashboard</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/11/20/crm2011-dialog-power-tips-run-a-dialog-from-a-dashboard/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/11/20/crm2011-dialog-power-tips-run-a-dialog-from-a-dashboard/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 15:22:27 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>
		<category><![CDATA[Form Script]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/11/20/dialog-power-tips-run-a-dialog-from-a-dashboard/</guid>
		<description><![CDATA[November 20, 2011 - Unlike workflows, dialog processes have a form-based UI, and like other forms in Dynamics CRM, they can be accessed directly by a URL. Sometimes the best way to expose these to users is from a link on a dashboard. This article explains how to do that dynamically, so a click on the link will always run the dialog as the current user.  Enjoy, and Happy Thanksgiving! ]]></description>
			<content:encoded><![CDATA[<h2>Allow Users to run a Dialog from a Dashboard Link</h2>
<p>Dialog processes, unlike workflows, must be started and run through to completion by a user. The standard way to kick them off is to select a record on a grid, click the Start Dialog button on the ribbon, and then select the dialog you want to run.</p>
<p>That&#8217;s a fine approach to take, but sometimes there are better ways to go. For example, suppose you&#8217;ve got a process to walk a receptionist through a phone conversation, and part of the process is to look up and check whether the caller is from an existing client. Depending on how the conversation goes, the process might end up creating one or more related records…but you don&#8217;t know before-hand <em>which</em> records will be created. Since the caller might not be a customer, you can&#8217;t write the process for an account or contact, and it&#8217;s a little artificial to force the creation of a lead record first … just to start a dialog process!</p>
<p>In scenarios like the one I just described it turns out the <em>user</em> record type is often the best choice for the <em>primary entity</em> of the process. That in turn raises another problem, in that it&#8217;s a little odd to require a user to navigate to their user record to start a dialog process.</p>
<p>Fortunately there&#8217;s a better way to do it, and for dialogs written for the user entity, <strong>intended to be run by the current user</strong>, the tip I describe here is the way to go. The basic idea is to create a dashboard with an HTML web resource that contains a hyperlink to run the dialog process. The link has to be constructed dynamically using JScript, and although the code might seem a little tricky if you don&#8217;t have much experience with HTML or scripting, the good news is, it&#8217;s highly re-usable code since it&#8217;s essentially the same thing every time.</p>
<p>The end result is illustrated in the following figure. I&#8217;ve got a &#8220;Refer Lead&#8221; dialog process exposed as a link in the dashboard component on the left, and I&#8217;ve placed a list of the current user&#8217;s referred leads in the component immediately to the right:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/11/112011_1522_DialogPower1.png" alt="" /></p>
<p>When the user clicks <strong>Refer Lead,</strong> the dialog opens in a new window, and the user runs through it as usual:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/11/112011_1522_DialogPower2.png" alt="" /></p>
<p>The approach I describe here uses a general technique in Dynamics CRM referred to as URL-addressable forms. This is very useful and comes up in many different contexts. I covered some of its uses and how to do it <a href="http://www.dynamicscrmtrickbag.com/2009/11/20/forms-tabsets/">in this article</a>.</p>
<p>To get a feel for how URL-addressable forms apply to dialogs, follow these steps:</p>
<ol>
<li>Run any dialog process and on the first page of the process press the Ctrl+N key combination, or press F11.</li>
<li>A new window opens, and the URL of the dialog process is exposed in the browser&#8217;s address bar.</li>
<li>Click the icon at the beginning of the URL, and drag and drop it onto your desktop.</li>
<li>Close the two open dialog windows and then double-click the shortcut on your desktop. Voila, the dialog runs correctly, and you&#8217;ve got a shortcut you can use any time you like.</li>
</ol>
<p>If you examine the nasty-looking URL, you can pretty much see what&#8217;s going on: it starts with the URL of your CRM organization, adds some stuff to tell CRM it&#8217;s a dialog you want to run, then refers to the dialog by its GUID, then refers to the user by its (ok, his or her) GUID. Here&#8217;s what a URL like that looks like:</p>
<p>https://businessprocessesindynamicscrm.crm.dynamics.com/cs/dialog/rundialog.aspx?DialogId=8C5CE987-7653-4ADD-AF10-EC52147FF0DF&amp;EntityName=systemuser&amp;ObjectId=FC09123D-2A32-417A-BA08-5C76D99BEDF6</p>
<p>It&#8217;s actually useful to understand the different components that make up a URL like that, and I provided a detailed description of them <a href="http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011-installment-5/">in this article</a>. Here&#8217;s a summary:</p>
<ul>
<li><a href="https://businessprocessesindynamicscrm.crm.dynamics.com">https://businessprocessesindynamicscrm.crm.dynamics.com</a> is the CRM organization URL.</li>
<li>/cs/dialog/rundialog.aspx instructs CRM you want to run a dialog.</li>
<li>?DialogId=8C5CE987-7653-4ADD-AF10-EC52147FF0DF is a query string instructing CRM which dialog to run, identifying it by its GUID.</li>
<li>&amp;EntityName=systemuser&amp;ObjectId=FC09123D-2A32-417A-BA08-5C76D99BEDF6 is another query string, this one specifying first the entity the dialog is written for, and then the GUID (&#8221;ObjectId&#8221;) of the record to run it for.</li>
</ul>
<p>So that URL will always run the dialog, but it will always run it as <em>you</em>. That is, the GUID of the user (FC09123D-2A32-417A-BA08-5C76D99BEDF6, in this case) is hardwired. To generalize this and create the dashboard solution that always runs the dialog as the <strong>current user</strong>, you really have to do two things:</p>
<ul>
<li>Figure out how to create a web resource with a hyperlink that can open up a URL-addressable form in a new window.</li>
<li>Figure out how to dynamically construct the user component of the URL. And while we&#8217;re at it, we might as well construct the organization URL dynamically too. That way, you can use the same basic code in any CRM organization.</li>
</ul>
<h2>Create the HTML Web Resource</h2>
<p>The first step is to create the HTML web resource. Navigate to Customizations, click Web Resources and then click <strong>New</strong>. Give it a good name and select <strong>Web Page (HTML)</strong> for the Type. Click Save and you will see the URL fill in, like the following figure illustrates:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/11/112011_1522_DialogPower3.png" alt="" /></p>
<p>Once you&#8217;ve saved it you can click the Text Editor button, then click the Source tab and you should see the following:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/11/112011_1522_DialogPower4.png" alt="" /></p>
<p>Just kidding! (or jk, as Jack would say) You actually have to enter the code yourself – it doesn&#8217;t just appear there.</p>
<p>Here&#8217;s the code:</p>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup span="1">
<col style="width: 638px;" span="1"></col>
</colgroup>
<tbody>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="font-family:Courier New; font-size:10pt">&lt;HTML&gt;&lt;HEAD&gt;<br />
</span><span style="font-family:Courier New; font-size:10pt">&lt;SCRIPT src=&#8221;../../ClientGlobalContext.js.aspx&#8221;&gt;&lt;/SCRIPT&gt;<br />
</span></p>
<p> </p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;SCRIPT type=text/javascript&gt;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">function safeNewWindow( url, title )<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">{<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">win = window.open(url, &#8220;_blank&#8221;,&#8221;height=600,width=800,modal=yes&#8221; );<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">if( win == null )<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">{<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">alert(&#8221;Your popup blocker has blocked the new window from opening.&#8221;);<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">}<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">else<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">{<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">//win.focus();<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">}<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">}<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;/SCRIPT&gt;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;META charset=utf-8&gt;&lt;/HEAD&gt;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;BODY contentEditable=true&gt;&amp;nbsp;<br />
</span></p>
<p><span style="font-family:Courier New; font-size:10pt">&lt;A onclick=&#8217;safeNewWindow(GetGlobalContext().getServerUrl()+&#8221;/cs/dialog/rundialog.aspx<br />
?DialogId=1F7A557F-3927-41D4-AF8F-7282B62358DD<br />
&amp;amp;EntityName=systemuser&amp;amp;ObjectId=&#8221;+GetGlobalContext().getUserId(), &#8220;Window Title Here&#8221; )&#8217; href=&#8221;#&#8221;&gt;Run Lead Referral Process&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;<br />
</span></td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<p>The first part – <span style="font-size:10pt">&lt;SCRIPT src=&#8221;../../ClientGlobalContext.js.aspx&#8221;&gt;&lt;/SCRIPT&gt; &#8212; is important because this HTML web resource is running from a dashboard. According to the Dynamics CRM SDK, &#8220;</span><span style="color:black; font-size:9pt">When you need context information outside a form, include a reference to the /webresources/ClientGlobalContext.js.aspx page in an HTML Web resource.</span><span style="font-size:10pt">&#8220;<span style="font-family:Courier New"><br />
</span>Read more on <a href="http://msdn.microsoft.com/en-us/library/gg328541.aspx">ClientGlobalContext</a>…<span style="font-family:Courier New"><br />
</span></span></p>
<p>The second part – everything in the next &lt;SCRIPT&gt;…&lt;/SCRIPT&gt; block – is a function contributed by my brilliant colleague Eric Reiner to open a window in a way Internet Explorer will considers safe. If you try to get this to work with a straight &lt;A href=url&gt;Click here&lt;/a&gt; approach, it throws an error and just sits there.</p>
<p>The third part is the URL that gets passed to the safeNewWindow function. Notice there are two calls to functions included in GetGlobalContext: getServerURL() is how we can dynamically construct the CRM organization URL, and getUserId() returns the GUID of the current user.</p>
<p>Using this approach, the only thing that&#8217;s hardwired is the <span style="font-family:Courier New; font-size:10pt">?DialogId=1F7A557F-3927-41D4-AF8F-7282B62358DD </span>part. That&#8217;s OK, though – since you&#8217;ll always know the dialog process you want to call (in this example, Refer Lead) it <em>should</em> be hardwired.</p>
<p>After creating your Web Page (HTML) web resource, be sure to publish it.</p>
<h2>Create the Dashboard</h2>
<p>The dashboard is the easy part. You can do this with either a personal dashboard or a system dashboard. To keep the steps to a minimum I used a personal dashboard in this example. Follow these steps:</p>
<ol>
<li>On the site map, click <strong>Workplace</strong> and then click <strong>Dashboards</strong>.</li>
<li>Click <strong>New</strong> on the ribbon.</li>
<li>Select any of the dashboard layouts, and then provide a name and save the dashboard.</li>
<li>Select one of the dashboard components, and then click <strong>Web Resource</strong>.</li>
<li>
<div>Click the browse button and you should be able to select the Web Page HTML web resource created above. (Not all web resources can be placed on a dashboard, but HTML web resources can be). This can get a little busy, especially if you&#8217;ve got the Activity Feeds solution installed, but if you look around a little you can find your web resource. The following figure shows my Refer Lead web resource selected in the lookup:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/11/112011_1522_DialogPower5.png" alt="" /></li>
</ol>
<p>Click <strong>OK</strong> a couple of times and you&#8217;re done.</p>
<p style="margin-left: 36pt"> </p>
<h2>Personal Dashboards or System Dashboards?</h2>
<p>Now you might wonder why I went to all that trouble to make a dynamic link that will run a dialog as the current user… but then exposed it on a personal dashboard that nobody except ME will ever see. Good point. Let&#8217;s contrast personal and system dashboards to decide which one is the best approach:</p>
<ul>
<li>A personal dashboard can by default be created by any user, and can only be seen by the user that created it. Personal dashboards are user-owned, so they can be assigned to a user, a team, and they can be shared out to users or teams.</li>
<li>A system dashboard is the opposite: it can only be created by a system administrator but when created it can be seen by everybody. System dashboards are organization owned, and are always visible to every user that can see <em>any</em> dashboards.</li>
</ul>
<p>Effectively, what these differences mean is that personal dashboards can be targeted, but system dashboards cannot be. So if you want some users to see a dashboard but not all users, a personal dashboard is the way to go. After creating it, you can either assign it to a user or a team, or share it with as many users or teams as required. If it&#8217;s shared/assigned to a user, or to a team of which a user is a member, the experience will be the same as it is if you create a personal dashboard. It&#8217;s available in the My Dashboards section of the Dashboard drop-down menu:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/11/112011_1522_DialogPower6.png" alt="" /></p>
<h1>Document Dialogs using the Description Field</h1>
<p>Lots of record types have description fields, and dialog and workflow processes are no exception. With processes – and especially dialogs – the <em>kind</em> of information you use the description fields for is a little different than the typical notes you&#8217;d enter about a customer or opportunity record.</p>
<p>For example, I wouldn&#8217;t normally enter your GUID on the description field of your contact record, but I&#8217;d definitely enter the GUID (&#8221;Dialog Id&#8221; as it&#8217;s referred to in the url as we saw previously) of a dialog in the Description field on the Administration tab of the process designer:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/11/112011_1522_DialogPower7.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/11/20/crm2011-dialog-power-tips-run-a-dialog-from-a-dashboard/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Building Business Processes in Dynamics CRM 2011: Installment 9</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/08/03/building-business-processes-in-dynamics-crm-2011-installment-9/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/08/03/building-business-processes-in-dynamics-crm-2011-installment-9/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 01:20:20 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011]]></category>
		<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/08/03/building-business-processes-in-dynamics-crm-2011-installment-9/</guid>
		<description><![CDATA[August 4, 2011 - Variables are an important new construct available only in CRM 2011 dialog processes, and store values during the life of a process. They're good for calculated fields, running sums and the like. In Installment 9 of the serialized version of my upcoming book, I describe how they work and present a highly scientific method of using them to score an opportunity record. Enjoy! ]]></description>
			<content:encoded><![CDATA[<p><!--         .style2         {             width: 90px;         }         .style3         {             width: 90px;             font-weight: bold;         }         .style4         {             width: 100px;             font-weight: bold;         }         .style5         {             width: 100px;         }      --></p>
<h2>Using Variables in Dialog Processes</h2>
<p>Variables are used for temporary data storage during the lifetime of a dialog. One of the most common reasons to use variables is to calculate a value based on other values. Here are a couple of examples where variables might be required:</p>
<ul>
<li>When a lead is converted to an opportunity, a sales representative might be prompted with several questions about the revenue potential, how supportive is the sponsor, what is the decision timeframe and so forth. Depending on the responses, an <strong><em>Opportunity Score</em></strong> variable could be calculated and used to update a custom field on the opportunity record.</li>
<li>A satisfaction survey or a post-even evaluation could be implemented with a dialog process. Individual survey responses could be captured in fields in a custom entity, but you might want to calculate aggregate values (totals, or averages, say) as well. You could use variables to hold these calculated values.</li>
</ul>
<p>You can create a new variable by clicking on the <em>Add</em> hyperlink in the <strong>Variables</strong> section of the process designer:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus1.png" alt="" /></p>
<p>As you can see in the following figure, variables have <strong>Name</strong>, <strong>Data Type</strong>, and <strong>Default Value</strong> properties:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus2.png" alt="" /></p>
<p>Notice in the previous figure that, just as when you specify the data type of the response in a prompt/response pair, the data type cannot be changed after saving. Some other important features to keep in mind:</p>
<ul>
<li>The <strong>Name</strong> property cannot contain spaces or special characters, and must be unique within the dialog process.</li>
<li>
<div>There are three options for the Data Type property:</div>
<ul>
<li>Use <strong>Single Line of Text</strong> for text values.</li>
<li>Use <strong>Whole Number</strong> for integer values, in the range of -2 billion or so to +2 billion or thereabouts.</li>
<li>The <strong>Floating Point</strong> data type supports values in the range -100,000,000,000 and 100,000,000,000, and more precision to the right of the decimal point.</li>
</ul>
</li>
</ul>
<p>You can see one of the differences between the <strong>Whole Number</strong> and <strong>Floating Point</strong> data types by comparing the <strong>Default Value</strong> field in the following two figures:</p>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup span="1">
<col style="width: 85px;" span="1"></col>
<col style="width: 85px;" span="1"></col>
</colgroup>
<tbody>
<tr>
<td style="padding-left: 7px; padding-right: 7px" colspan="2"><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus3.png" alt="" /></td>
<td style="padding-left: 7px; padding-right: 7px"><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus4.png" alt="" /></td>
</tr>
</tbody>
</table>
</div>
<h3>Example: Using Variables to Score Opportunity Records</h3>
<p>Let&#8217;s walk through the <strong><em>Score Opportunity</em></strong> dialog process example in detail. It&#8217;s written for the Opportunity entity, and as in the previous example, is available to run both <strong>As an on-demand process</strong> and <strong>As a child process</strong>. The following figure shows <strong>Properties</strong> section, the <strong>Variables</strong> section expanded so you can see the <strong>OpportunityScore </strong>variable, and the three main stages of the dialog collapsed so you can see everything at once:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus5.png" alt="" /></p>
<p>I&#8217;ll drill down on each of the stages in succession.</p>
<li>
<h4>Stage 1: Prompt and Collect Responses</h4>
<p>The following figure shows stage 1 expanded:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus6.png" alt="" /></p>
<p>Stage 1 contains the single page of this dialog process, which exposes the prompt/response pairs. In the previous figure, the <strong><em>Decision Timeframe</em></strong> Prompt and Response is highlighted; clicking <strong>Set Properties</strong> opens the following <strong>Define Prompt and Response</strong> dialog:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus7.png" alt="" /></p>
<p>The most important things to notice here are:</p>
<ul>
<li>Notice the <strong>Data Type</strong> is set to <strong>Integer</strong>. We discussed this previously, but I want to emphasize the importance of getting this right the first time in. <strong>Text</strong> is the default, and I can&#8217;t tell you how many times I&#8217;ve forgotten to change it in situations when I really need the <strong>Integer</strong> value. It can take a while to specify the several response values for an option set…and if you get the data type wrong the only way to fix it is to delete and start over!</li>
<li>
<div>Next, notice that the 3-6 months Response Value is selected, and the values of the associated <strong>Value</strong> and <strong>Label</strong> properties. These really define the business rules behind the specific opportunity scoring algorithm being designed, and will of course vary from one organization to another (not to mention the questions!). But to give you a feel for how this can work, the following table lists the values for each of the four possible responses for the <strong>Decision Timeframe</strong> prompt, along with my thought process for the values:</div>
</li>
</ul>
<div style="margin-left: 41pt">
<table style="width: 95%;" border="1" cellpadding="5">
<tbody>
<tr>
<td class="style3" bgcolor="activecaption">Response Label</td>
<td class="style4" bgcolor="activecaption">Response Value</td>
<td bgcolor="activecaption"><strong>Thought Process</strong></td>
</tr>
<tr>
<td class="style2">Less than 3 months</td>
<td class="style5">0 </td>
<td>Too quick; an indication we&#8217;re coming in late and may be proposal fodder</td>
</tr>
<tr>
<td class="style2">3-6 months<strong> </strong></td>
<td class="style5">10</td>
<td>The sweet spot.</td>
</tr>
<tr>
<td class="style2">6+ months<strong> </strong></td>
<td class="style5">5</td>
<td>More than 6 months might be a little better than less, but it&#8217;s not as good as<br />
3-6.</td>
</tr>
<tr>
<td class="style2">Don&#8217;t know/won&#8217;t say</td>
<td class="style5">-5</td>
<td>Either we haven&#8217;t done our homework to find out, or the customer won&#8217;t tell us.<br />
Either way it&#8217;s bad, so we deduct points from the score.</td>
</tr>
</tbody>
</table>
</div>
<h4>Stage 2: Calculate OpportunityScore Variable using Assign Value</h4>
<p>In stage 2, we use <strong>Assign Value</strong> to successively increment the <strong><em>OpportunityScore</em></strong> variable. You can see this in the following figure, which shows stage two expanded with the <strong><em>Increment by Timeframe</em></strong> score step highlighted:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus8.png" alt="" /></p>
<p>Clicking on <strong>Set Properties</strong> for that step shows the following <strong>Assign Value</strong> dialog:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus9.png" alt="" /></p>
<p>This ties back to the point I made in describing stage 1, about the importance of the <strong>Integer</strong> data value in this case. The value of the <strong><em>OpportunityScore</em></strong> variable is incremented here by the <strong>Response Value</strong> of the <strong><em>Decision Timeframe</em></strong> response. If I&#8217;d forgotten to specify <strong>Integer</strong> as the data type, the <strong>Response Value</strong> drop-down in the Dynamic Values section would be depressingly empty, reminding me too late that (once again!) I went too fast in the Prompt and Response dialog and got the wrong data type.</p>
<p>Another thing to watch out for here is the option selected for the <strong>Operator</strong>. For a cumulative score like the one calculated in this process, <strong>Increment By</strong> is the way to go. The first time I wrote a scoring dialog process like this one, I accidentally selected <strong>Set to</strong> on the very last <strong>Assign Value</strong> step in the stage. When testing it, I kept wondering why no matter how good or bad I scored all the rest of the questions, the overall score never got much above or below zero. Don&#8217;t let that happen to you!</p>
<p>For numeric fields, the operators you can use <strong>Set to</strong>, <strong>Increment by</strong>, <strong>Decrement by</strong>, <strong>Multiply by</strong>, and <strong>Clear</strong>. (No <strong>Divide by</strong>. Bummer!) You can see them all here:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus10.png" alt="" /></li>
<li>
<h4>Stage 3: Update Custom Field on Opportunity with OpportunityScore Variable</h4>
<p>Stage 3 is the easiest to understand, since all it does is use the calculated value of the <strong><em>OpportunityScore</em></strong> variable to update the opportunity record:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus11.png" alt="" /></p>
<p>Click <strong>Set Properties</strong> to open the <strong>Update Opportunity</strong> dialog. The following figure shows how I update it in this example:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus12.png" alt="" /></p>
<p>In this example, I added a custom field, <strong><em>Opportunity Score</em></strong>, to the opportunity entity. I defined it as a <strong>Whole Number</strong> data type. This is important because it corresponds to the data type for the <strong><em>OpportunityScore</em></strong> variable in the dialog, which here is used to update the field value on the record.</p>
<p>Notice that <strong>Dialog</strong> is selected in the <strong>Look for</strong> drop-down. This is a special value that is used specifically to expose variables in dynamic values for dialog processes. You can verify this the next time you&#8217;re in the dialog designer working on a dialog without any variables defined, in which case <strong>Dialog</strong> will not appear in the <strong>Look for</strong> drop-down.</p>
<p>Here&#8217;s what it looks like when it&#8217;s there:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus13.png" alt="" /></li>
<li>
<h4>How it Works</h4>
<p>Let&#8217;s take a look at the user experience for the <strong><em>Score Opportunity</em></strong> dialog process. First, remember that it&#8217;s written for the opportunity record type and it&#8217;s available to run as an on-demand process. This means it can be run by clicking <strong>Start Dialog</strong> with an opportunity record selected on the data grid, or from the ribbon on the opportunity form.</p>
<p>From the data grid:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus14.png" alt="" /></p>
<p>Of from the form:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus15.png" alt="" /></p>
<p>After selecting <strong><em>Score Opportunity</em></strong> and kicking it off, here&#8217;s what the dialog process looks like:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080411_0119_BuildingBus16.png" alt="" /></p>
<p>This dialog has a single page only, so after clicking <strong>Next</strong> and then <strong>Finish</strong>, the dialog gathers the responses, uses them to update the <strong><em>OpportunityScore</em></strong> variable, which in turn is used to update the opportunity record.</p>
<p>Here are a couple of observations on some of the business issues a process like this might raise:</p>
<ul>
<li>Notice that the implementation details of a process like this one impose some business rules. In this example, they mean that an opportunity can be scored more than once. This may be appropriate for some organizations, but you can also imagine imposing a &#8220;score once only&#8221; rule. Suppose instead of creating the dialog process for the opportunity record type and making it available for on-demand use, you only exposed it for use as a child process, and called it from a custom lead conversion process. This would effectively enforce the score once only rule…especially if you remember to take the <strong><em>Opportunity Score</em></strong> field off the opportunity form!</li>
<li>The way I wrote this dialog process, the <strong><em>OpportunityScore</em></strong> field ranges from a maximum value of 50 to a minimum of -50. While there&#8217;s nothing particularly scientific about the approach I used, I&#8217;ve known sales managers who claim to have a fool-proof lead qualification process consisting of a small number of simple questions a relatively inexperienced sales rep can ask a potential customer. If you&#8217;re in that category, here&#8217;s your chance to bake it into your CRM!</li>
</ul>
</li>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/08/03/building-business-processes-in-dynamics-crm-2011-installment-9/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building Business Processes in Dynamics CRM 2011: Installment 8</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/08/02/building-business-processes-in-dynamics-crm-2011-installment-8/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/08/02/building-business-processes-in-dynamics-crm-2011-installment-8/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 17:15:55 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011]]></category>
		<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/08/02/building-business-processes-in-dynamics-crm-2011-installment-8/</guid>
		<description><![CDATA[August 2, 2011 - One reason to call a child dialog is to let a user do the same thing again: that's recursion, and I explained that in Installment #7. Another reason is reuse: call the same child process from several different parent processes. And that, my friend, is the topic of Installment #8 of my upcoming book, Building Business Processes in Dynamics CRM 2011.]]></description>
			<content:encoded><![CDATA[<h2>Calling Child Processes with <em>Link Child Dialog</em>: Reusable Dialog Processes</h2>
<p>Previously we discussed calling a child dialog process to implement a recursive process. The other reason to use child dialogs is when you have several dialog steps <em>in common</em> across different dialog processes: if you break them out and put them into their own dialog process you can make your dialogs easier to understand, and easier to maintain.</p>
<p>For example, suppose you have several e-mail templates and you want to build a dialog process that prompts sales representatives with the templates, allowing them to select one and send the appropriate e-mail to a contact. While this might be a relative simple dialog process, it also might be used in several different contexts: when a new contact is associated with an account, when a lead is converted to a contact, or as a follow-up after a conversation with an existing contact. If each of <em>these</em> is implemented as a dialog process, it can be considerably easier to create a <em>separate</em> dialog for the e-mail selection, rather than replicating the same steps in each of the other processes. The following two diagrams provide a heuristic illustration of the difference:</p>
<p><strong>Figure 1: Non-Modular Processes<br />
</strong></p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus1.png" alt="" width="578" height="122" /></p>
<p><strong>Figure 2: Modular Processes<br />
</strong></p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus2.png" alt="" width="582" height="246" /></p>
<p>With the non-modular approach, if you want to change the logic of the second part of the processes, you have to modify three separate processes. With the modular approach you only have to modify one. As with the recursive dialog example, remember to select the <strong>Available as a child process</strong> option in order to make a dialog &#8220;callable&#8221; from a parent process.</p>
<p>The following figures illustrate this in the Dynamics CRM 2011 dialog designer, starting with the dialog properties:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus3.png" alt="" width="573" height="179" /></p>
<p>This dialog is divided into three stages, as the following figure shows. (The <strong>Input Arguments</strong> and <strong>Variables</strong> sections are not used in this dialog, so they&#8217;re minimized to save space.)</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus4.png" alt="" width="587" height="466" /></p>
<p>Now let&#8217;s see how this works, examining the main action in each of the three stages, respectively: the query properties, the prompt and response properties, and the send e-mail properties.</p>
<h3>Query Properties:</h3>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus5.png" alt="" /></p>
<p>The Query properties are straightforward. In the current example, we simply query for all e-mail templates for contact records. As you will see below, I use the default templates, but in the real world you will likely delete those templates and create new ones for your business.</p>
<p>This is a &#8220;static&#8221; query, in the sense that we are not using the <strong>Modify Query Variables</strong> tab to dynamically filter the query. However, it would be possible to extend this, for example by making the filter dynamically select different template types depending on the context. The potential payoff for the added complexity? More re-use: imagine an <em>ube</em>r-email template selection process that works whether for a contact, a lead, or any other record type you want to send e-mails to.</p>
<h3>Prompt and Response Properties:</h3>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus6.png" alt="" /></p>
<p>The Prompt and Response properties are similar to ones we&#8217;ve seen before, with <strong>Provide Values</strong> set to <strong>Query CRM data</strong>, and the <strong>Query Variables</strong> provided by the previously defined query, <strong><em>Contact E-Mail Templates</em></strong>. Perhaps the most interesting thing about this example is the use of dynamic values in the <strong>Prompt Text</strong> field. Both the <strong>Prompt Text</strong> and <strong>Tip Text</strong> fields can take advantage of dynamic values to make your dialog processes more…well, dynamic. We&#8217;ll see more examples of this later in the book.</p>
<div><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus7.png" alt="" /></div>
<h3>Send E-mail Properties:</h3>
<p>The Send E-Mail properties are where we specify the recipient on the <strong>To</strong> line (the contact), and select the appropriate template. Remember, this happens inside the conditional block, based on the value of the Selected Template (the response value from the prompt and response in stage 2).</p>
<p>Notice that in this example I left the <strong>From</strong> field empty. If you do this, the e-mail will be sent from the user running the dialog process. An alternative would be to fill this field with the owner of the contact record, but that would introduce the possibility of the e-mail being sent on behalf of another user. Depending on your business requirements, that may be the way to go, but it can also introduce complexity.</p>
<p>After saving, closing and activating this process, it can be run on an on-demand basis, by selecting a contact record, clicking <strong>Start Dialog</strong> on the ribbon, and selecting the dialog process:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus8.png" alt="" /></p>
<p>Once more, the reason this dialog is available to run from the UI like this is that the <strong>As an on demand process</strong> property is selected. Since the point of this exercise was to illustrate how to use child dialog processes, you can think of this as a bonus!</p>
<p>Here&#8217;s what it looks like when you call this dialog, using the <strong>Link Child Process</strong> step, from another dialog:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus9.png" alt="" /></p>
<p>Again, the reason you can call it like this is because the <strong>Available as a child process</strong> property is selected. In the next section we will examine how to pass values from a parent dialog process to a child. But in the meantime, here are a few tips and hints that apply to all cross-dialog conversations initiated with <strong>Link Child Dialog</strong>:</p>
<ul>
<li>
<div><em>When a Dynamics CRM 2011 parent process calls a child process, the context of the parent process is passed to the child process.</em> This is an important improvement compared to Dynamics CRM 4.0, where although a workflow could call a child workflow, the child new nothing about the context of the parent. You can see this in the following figure:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus10.png" alt="" /></p>
<p>The process you&#8217;re linking <em>to </em>(in this case, the <strong><em>Select Template, Send E-Mail</em></strong> example) knows which contact record you&#8217;re on when you call it. Notice you can also call processes written for entities in the <strong>Related Entities</strong> section. And as you remember from our previous discussion in the workflows section of the book, these are all of the entities that are parent entities of the entity this process is written for. So for example, if you have a dialog process for the account entity and it&#8217;s exposed as a child process, you can call it from here and the process engine will know to call the parent customer of the current contact record</li>
<li>
<div><em><strong>Link Child Dialog</strong> can only be used as the last step in a dialog process!</em> That is, you cannot pass control to a child dialog and then pick up where you left off in the parent dialog when done. If you try to activate a dialog using Link Child Dialog where it is not the last step in the dialog, you get the following error:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080211_1715_BuildingBus11.png" alt="" /></p>
<p>Interestingly, you can pass control to a child workflow (using the <strong>Start Child Workflow</strong> step) and then return to the parent process, picking up where you left off. This is because workflows run asynchronously and don&#8217;t support user interaction. You must be careful with this, however: because workflows are asynchronous, you cannot depend on their being completed when you return to the calling process! We will see an example of this later in the book; for now, file it in your &#8220;things to watch out for&#8221; category.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/08/02/building-business-processes-in-dynamics-crm-2011-installment-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Business Processes in Dynamics CRM 2011: Installment 7</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/08/01/building-business-processes-in-dynamics-crm-2011-installment-7/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/08/01/building-business-processes-in-dynamics-crm-2011-installment-7/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 22:17:48 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011]]></category>
		<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/08/01/building-business-processes-in-dynamics-crm-2011-installment-7/</guid>
		<description><![CDATA[August 1, 2011 - Recursive dialogs are simpler than recursive workflows, which probably accounts for why Installment 7 from my upcoming book (Building Business Processes in Dynamics CRM 2011) is so short. I also include a link to a video. Enjoy!]]></description>
			<content:encoded><![CDATA[<h1>Calling Child Processes with Link Child Dialog: Recursive Dialog Processes</h1>
<p>Dialogs, like workflows, can call child processes. The action you use to call a child dialog from a parent is <strong>Link Child Dialog</strong>, analogous to the <strong>Start Child Workflow</strong> action available for workflow processes.</p>
<p>And similarly to workflows, there are two main scenarios when you will want to call a child dialog process:</p>
<ul>
<li><strong>When you have a recursive process</strong>. Suppose you have a dialog process that gathers information from a user and then uses that information to create a case record for an account. If you want to provide the option of creating several cases without requiring the user to select the account record and repeatedly start the dialog from the ribbon, this is a job for a recursive process, in which a dialog can repeatedly call <em>itself</em> as a child process.</li>
<li><strong>When you have modular dialog processes you want to re-use</strong>. For example, you may have a standard dialog process that allows a user to select one of several e-mail templates to construct and send a case acknowledgment e-mail to a customer after creating a case record. If several different case creation processes all use this standard process for sending the acknowledgment e-mail, breaking it out separately as a shared child process means you only have to change it in one place, if and when you need to make changes to it.</li>
</ul>
<h2>Recursive Dialog Processes</h2>
<p>Let&#8217;s examine a recursive dialog process, using the create-multiple-cases example just mentioned. The following figure shows how the properties for such a dialog, in this example named <strong>Create Cases for Account</strong>, might look:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080111_2217_BuildingBus1.png" alt="" /></p>
<p>The most important point here is that both the <strong>As an on-demand process </strong>and <strong>As a child process</strong> options must be selected in the <strong>Available to Run</strong> section. If the first one isn&#8217;t selected you&#8217;d have no way of kicking off the dialog in the first place; if the second isn&#8217;t selected the dialog won&#8217;t be able to call itself recursively.</p>
<p>Now let&#8217;s take a look at the dialog logic, first in a Visio diagram:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080111_2217_BuildingBus2.png" alt="" /></p>
<p>Now in the dialog designer:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/08/080111_2217_BuildingBus3.png" alt="" width="660" height="356" /></p>
<p>In the previous figure, clicking <strong>Set Properties</strong> on the <strong>Link Child Dialog</strong> step will allow you to browse and select the Create Cases for Account process. Again, you will only be able to select this process if <strong>As a child process</strong> is selected in the <strong>Available to Run</strong> section.</p>
<p style="margin-left: 36pt"><span style="font-family:Cambria"><strong>Tip: Select &#8220;As a child process&#8221;, then click Save<br />
</strong></span></p>
<p style="margin-left: 36pt">In order to call a dialog process from itself – to recurse, that is – it must be available to run as a child process. When you first create one of these, if you select <strong>As a child process</strong> and immediately attempt to add the <strong>Link Child Dialog</strong> step, you may notice that the dialog is not available. This is most likely because you haven&#8217;t saved the dialog after selecting the <strong>As a child process</strong> option. So remember: after you select that option, save the dialog, and then you can browse to the process, calling it recursively with <strong>Link Child Dialog</strong>.</p>
<h2>Summing Up, and an Illustrative Video</h2>
<p>You can use the same basic recursion technique with Dynamics CRM workflows. For example, you can use a recursive workflow to manage a case escalation process: a case record is routed to a queue upon creation, the workflow uses a Wait/Timeout condition to enforce a service level agreement. If the SLA is violated, the workflow calls itself recursively after updating an escalation level field on the case record. Logic in the workflow handles escalated cases differently from new ones. But even from that 3-sentence explanation you can tell recursive <em>workflows</em> are more complicated than recursive <em>dialogs</em>, which are really quite simple. I use them a lot, so far mainly for the &#8220;would you like to do it again&#8221; scenario covered here, although I&#8217;m sure there are other good uses.</p>
<p>Here&#8217;s a video, taken from a recent training session I gavem that shows how to do this:</p>
<p><a href="http://youtu.be/x53CAYq1Zzc" target="_blank">Creating Recursive Dialog Processes with Link Child Dialog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/08/01/building-business-processes-in-dynamics-crm-2011-installment-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Business Processes in Dynamics CRM 2011: Installment 6</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/07/24/building-business-processes-in-dynamics-crm-2011-installment-6/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/07/24/building-business-processes-in-dynamics-crm-2011-installment-6/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 02:25:02 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011]]></category>
		<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/07/24/building-business-processes-in-dynamics-crm-2011-installment-6/</guid>
		<description><![CDATA[July 27, 2011 - Here's Installment 6 of my upcoming book, "Building Business Processes in Dynamics CRM 2011". This one is from a chapter I call "Business Processes in the Real World", which builds on the previous chapters and basically consists of lots of examples of useful workflows and dialogs. This one's about using dialogs to create, convert and close records, and while it's probably too long for a blog post, I wanted to cover the entire topic. Enjoy!]]></description>
			<content:encoded><![CDATA[<h2>Use Dialogs to Create, Convert and Close Records</h2>
<table border="0" cellpadding="12">
<colgroup span="1">
<col span="1" valign="top" width="50%"></col>
</colgroup>
<tbody>
<tr>
<td><strong>July 27, 2011</strong> Users of Dynamics CRM are constantly creating new records, using the information on one record to assist in the creation of another, closing records as &#8220;won&#8221; or &#8220;lost&#8221;, and so forth. These scenarios have much in common, and as you will presently see, dialog processes can be applied to good effect. First let&#8217;s examine these scenarios in more detail, and then see how custom dialogs can improve the user experience.</td>
<td style="text-align: left;" bgcolor="lightblue">This article is an excerpt from my upcoming book, <em><strong>Building Business Processes in Dynamics CRM 2011</strong></em>. Others in the series:</p>
<ul>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/20/building-business-processes-in-dynamics-crm-2011-installment-1/">Installment #1: Introduction to Dialog Processes</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/21/building-business-processes-in-dynamics-crm-2011-installment-2/">#2: Prompts and Responses in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/25/building-business-processes-in-dynamics-crm-2011-installment-3/">#3: Actions and Conditions in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/27/building-business-processes-in-dynamics-crm-2011-installment-4/">#4: Querying CRM Data in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011-installment-5/">#5 Calling Dialog Processes with a URL</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<h3>Creating Records</h3>
<p>The standard user experience in Dynamics CRM is <em>form-centric</em>: to create a new record, navigate to the appropriate data grid, click the <strong>New</strong> button and fill out the form. Generally that approach works well and it&#8217;s often the best way to go…but not always. Consider the following scenarios:</p>
<ul>
<li>A phone receptionist fields incoming calls and enters the appropriate information into Dynamics CRM. But she doesn&#8217;t know before-hand what the call will be about, what kind of information needs to be entered and so forth. It might be an existing customer inquiring about a case, it might be a brand new lead, it might be an existing customer requesting an upgrade.</li>
<li>An outside sales representative is charged with creating &#8220;call reports&#8221; after meetings with clients. Certain key pieces of information are always recorded for the call report: date, account, contact, notes, next steps, whether it was regarding an opportunity and so on. Sometimes, but not always, a new opportunity should be created as a result. He is not a heavy-duty CRM user, and needs a simpler experience than the standard form-centric one.</li>
</ul>
<p>In both of those scenarios, dialog processes can provide a better experience than the standard forms.</p>
<p>In the first one she doesn&#8217;t even know before-hand what kind of records need creating, so she&#8217;d have to quiz the caller first to figure it out, and then re-quiz them once she gets the proper form(s) open. A dialog process can prompt, and based on the responses figure out which records need to be created, and use the response values to create the new records, however many different kinds need to be created!</p>
<p>In the second one the advantages are more about ease of use: rather than turning a task-centric user loose on one or more potentially complex forms, a dialog can simply ask a few questions, and use the provided responses to create the call report, as well as, optionally, the opportunity record.</p>
<h3>Converting Records</h3>
<p>A related scenario is <em>converting</em> records: where you&#8217;ve already got information entered, and you want to create a new, related record but don&#8217;t want to re-enter everything. The classic example is the <strong>Convert Lead</strong> dialog: provided we can sort through all the possible permutations, we can take the information on a lead record and use it to create various combinations of account, contact and opportunity records:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus1.png" alt="" /></p>
<p>Plenty of other record types can be converted as well. For example, all activity type records (including custom activities) can be converted to opportunities or cases, or &#8220;promoted&#8221; to create a campaign response. But only e-mail activities can also be converted to leads. I always wondered, why stop there? Why couldn&#8217;t other activities be a good source of information for a lead or another record type?</p>
<p>With the previous discussion in mind, here are two good potential uses of dialog processes for record conversions:</p>
<ul style="margin-left: 40pt">
<li><strong>Replace the default lead conversion process</strong>. Not only is it confusing, but many organizations do not need or want all the options it makes available. For example, a company might have business rules requiring that opportunity records are always associated with an account, and never with a contact record. A custom dialog to replace the standard one could both simplify the conversion process and enforce this rule.</li>
<li><strong>Allow the conversion of activities to additional record types</strong>. Perhaps an organization wants to allow phone calls or other activities to be converted to lead records. Or a service scheduler might want to use the information on a phone call activity to create a new service activity. Custom dialog processes can perform jobs like this nicely.</li>
</ul>
<h3>Closing Records</h3>
<p>Then there&#8217;s the issue of &#8220;closing&#8221; records. What records need to be closed and why do we want to close them? To answer questions like this one, have some empathy for your Dynamics CRM record types:</p>
<ul style="margin-left: 40pt">
<li><strong>Lead</strong> records want to be qualified, converted into a combination of account, contact and opportunity records. (see above)</li>
<li><strong>Account</strong> and <strong>contact</strong> records don&#8217;t want to be closed: they want to be part of your CRM forever.</li>
<li><strong>Cases</strong> want to be resolved, with a high level of customer satisfaction.</li>
<li><strong>Opportunities</strong> ache to be closed as Won…but they&#8217;d rather be closed as Lost than sit out there forever with an Est. Close Date somewhere in the distant past.</li>
</ul>
<p>So far I&#8217;ve used the term &#8220;closed&#8221; loosely, generally referring to an inactive record, and one that cannot be modified. When you roll up your sleeves and get to work in Dynamics CRM, however, it&#8217;s important to be more precise! In particular, we will examine the &#8220;close processes&#8221; in some detail for three standard record types (lead, case and opportunity), and also for custom entities. The issue is that all of these record types have default close processes, and if the default processes don&#8217;t meet your business requirements you can create custom ones with Dynamics CRM 2011 dialog processes.</p>
<p>Dialog processes are the way to go in these situations, because they support user interaction, which is a practical necessity for closing out records according to specific business rules. The <strong>Convert Lead </strong>dialog was shown previously, and the following table illustrates the default <strong>Resolve Case</strong> and <strong>Close Opportunity</strong> dialogs:</p>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup span="1">
<col style="width: 317px;" span="1"></col>
<col style="width: 322px;" span="1"></col>
</colgroup>
<tbody>
<tr style="background: #4f81bd">
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2"><span style="color:white"><strong>Case Resolution</strong></span> </td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><span style="color:white"><strong>Opportunity Close</strong></span> </td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2"><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus2.png" alt="" width="285" height="290" /></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus3.png" alt="" width="289" height="297" /></td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<p>Again: nothing particularly wrong with the defaults, other than the fact that they might not meet your business requirements. In Dynamics CRM 4.0 there was a bigger barrier to implementing custom processes to replace the defaults, since that required a combination of plug-in and ASP.NET code to accomplish. But in Dynamics CRM 2011 we have use dialog processes for this, and in the next section we will see some examples.</p>
<p> </p>
<h3>Example: Custom Lead Conversion Process to Check for Existing Contact Records</h3>
<p>Another common problem encountered when converting lead records has to do with checking for and flagging potential duplicate records. For example, some organizations use a unique e-mail address rule to identify and prevent duplicate records. But for other organizations, several contacts sharing the same e-mail address is a common occurrence and should not necessarily be prevented.</p>
<p><em>Whatever</em> business rules you implement for duplicate checking, the lead conversion process is a choke point you really should try to take advantage of before creating a new contact record. The Dynamics CRM default lead conversion process does not handle duplicate checking very well, but its shortcomings are easily overcome with a custom dialog process like the example I cover next.</p>
<p>First, though, let&#8217;s take a quick look at the problems with the default lead conversion process when it comes to duplicate records. In this example, I&#8217;ll use the default Duplicate Detection Rules you can see if you navigate to <strong>Settings-&gt;Data Management-&gt;Duplicate Detection Rules</strong>:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus4.png" alt="" /></p>
<p>Suppose when a lead record is converted to a contact, you want users to be <em>prompted</em> if a contact with the same e-mail address already exists. But there&#8217;s no hard and fast rule against multiple contacts with the same e-mail address, so you want to give them the discretion to go ahead and create the record if appropriate.</p>
<p>With the default duplicate detection rules published, suppose you select a lead record on the data grid and click <strong>Qualify</strong>. The <strong>Convert Lead</strong> dialog opens. You make the following selections, not knowing if any existing contacts have the same e-mail address as the lead you&#8217;re converting:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus5.png" alt="" /></p>
<p>If an existing contact record has the same e-mail address as the lead, here&#8217;s what you will see:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus6.png" alt="" /></p>
<p>The problem here is that the lead conversion process tries to create a new contact record, a matching e-mail is detected, and you are prevented from creating the record.</p>
<p>Contrast that with creating a new contact record directly (that is, rather than by converting a lead record). In this scenario a potential duplicate opens the <strong>Duplicates Detected</strong> dialog, which gives you the option of going ahead and saving the record:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus7.png" alt="" /></p>
<p>Since the default lead conversion process does not give us the flexibility we want when converting leads, we can create a custom dialog process that does. Here&#8217;s an example of the user experience, starting from a lead form and running the <strong>Convert Lead, Check for Contact</strong> dialog process:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus8.png" alt="" /></p>
<p>This custom dialog performs a query of contact records, and conditionally displays the above Prompt and Response if one or more are found with the same e-mail as the lead. The following figure presents the process logic in a Visio diagram:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus9.png" alt="" /></p>
<p>The dialog is created for the Lead entity, as you can see in the Properties section:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus10.png" alt="" /></p>
<p>In the Step Editor, I&#8217;ve broken the dialog into four stages, and I&#8217;ll explain them in turn next. <strong>Stage 1</strong> is short, and only contains the <strong>Query CRM Data</strong> step:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus11.png" alt="" /></p>
<p>Here&#8217;s what the Query itself looks like (what you&#8217;d see if you clicked <strong>Set Properties</strong> in the previous figure):</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus12.png" alt="" /></p>
<p>This should be familiar from the discussion previously in the book on building dynamic queries in dialogs. The query is a simple one with two conditions. The first one filters for active contact records. The second one (highlighted) is more interesting: it takes the E-mail of the selected lead record and passes it into the query by means of the &#8220;Variable2&#8243; parameter.</p>
<p><strong>Stage 2</strong> handles the &#8220;no matches found&#8221; condition. Here&#8217;s what it looks like:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus13.png" alt="" /></p>
<p>After the query is performed, the <strong>Statement Label</strong> of the query (&#8221;Contacts with matching E-mail&#8221;) will be available as a <strong>Local Value</strong> and its special property <strong>Records</strong> can be used to see how many rows are returned. In the previous figure, you can see that if no matching e-mails are found, the return value will be 0, in which case the new contact record is created, the lead qualified, and then we&#8217;re done.</p>
<p>On to <strong>Stage 3</strong>, which handles the &#8220;matches found&#8221; scenario:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus14.png" alt="" /></p>
<p>Stage 3 contains this dialog&#8217;s only page, which contains two prompt/response pairs. The first is a simple No/Yes option; the response value is used in Stage 4. The second simply displays the matching records so the user can examine them. Here&#8217;s what that looks like (what you&#8217;d see if you clicked the second <strong>Set Properties</strong> button in the figure):</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus15.png" alt="" /></p>
<p>Notice that <strong>Query CRM data</strong> is used for the prompt values, and that the Label of the query step (back in Stage 1) is what is selected in the <strong>Query Variables</strong> drop-down. (Statement labels are important in dialog processes, because they&#8217;re always showing up later in the dialog as something you need to refer to. More discussion of this important point in the <em>Tips, Tricks and Best Practices</em> chapter.)</p>
<p>Now we come to <strong>Stage 4</strong>, which has a conditional block that takes appropriate action depending on the value of the <strong>Create Contact? Response Label</strong> (No, or Yes):</p>
<p> </p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/07/072511_0222_BuildingBus16.png" alt="" /></p>
<p>If No was selected, we disqualify the lead and stop the dialog; if Yes, create the contact record, qualify the lead and we&#8217;re done. Since this is the last stage in the dialog, it would function identically even if the Stop dialog step was not included in the No block, but I usually add it anyway for better readability.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/07/24/building-business-processes-in-dynamics-crm-2011-installment-6/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Building Business Processes in Dynamics CRM 2011: Installment 5</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011-installment-5/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011-installment-5/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 14:42:17 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011]]></category>
		<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011-installment-5/</guid>
		<description><![CDATA[June 28, 2011 - In Installment 5 of my upcoming book, Building Business Processes in Dynamics CRM 2011, I cover an important topic for customizers: calling dialog processes with a URL. ]]></description>
			<content:encoded><![CDATA[<h2>Calling Dialog Processes with a URL</h2>
<table border="0" cellpadding="12">
<colgroup span="1">
<col span="1" valign="top" width="50%"></col>
</colgroup>
<tbody>
<tr>
<td><strong>June 28, 2011</strong> The first time you read that in addition to starting a dialog manually from the ribbon in the usual way, you can also kick one off by referencing its URL you might wonder what that could be used for. This turns out to be a very important method of customizing the user experience, because it means that you can place custom buttons on the application ribbon or form ribbons in Dynamics CRM 2011, and give users one-click access to dialog processes.</td>
<td style="text-align: left;" bgcolor="lightblue">This article is an excerpt from my upcoming book, <em><strong>Building Business Processes in Dynamics CRM 2011</strong></em>. Others in the series:</p>
<ul>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/20/building-business-processes-in-dynamics-crm-2011-%3Cdiv%20%20mce_tmp=">installment-1/&#8221;&gt;Installment #1: Introduction to Dialog Processes</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/21/building-business-processes-in-dynamics-crm-2011-%3Cdiv%20%20mce_tmp=">installment-2/&#8221;&gt;#2: Prompts and Responses in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/25/building-business-processes-in-dynamics-crm-2011-%3Cdiv%20%20mce_tmp=">installment-3/&#8221;&gt;#3: Actions and Conditions in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/27/building-business-processes-in-dynamics-crm-2011-%3Cdiv%20%20mce_tmp=">installment-4/&#8221;&gt;#4: Querying CRM Data in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011-%3Cdiv%20%20mce_tmp=">installment-5/&#8221;&gt;#5 Calling Dialog Processes with a URL</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Ultimately, what we want is something like a custom button on a ribbon which we can use to start a dialog process. But in order to address this topic properly, we need to take a step back and discuss a couple of slightly more fundamental topics first.</p>
<h3>What Entity Should a Dialog be Written for?</h3>
<p>Sometimes it&#8217;s obvious which entity a dialog should be written for, but just as with workflow processes, sometimes it&#8217;s not. Here are a couple examples of when it&#8217;s an easy decision:</p>
<ul>
<li>If you want an interactive process where a user selects a record and then makes a copy of it, changing a few values in the process, the dialog should be written for the record type you want to copy. Case to case, opportunity to opportunity, and so forth.</li>
<li>Suppose you want to create an alternative to the standard lead qualification process. Since you&#8217;d want to start the process from the context of a selected lead record, create this dialog process for the lead entity.</li>
</ul>
<p>On the other hand, consider the following business requirements:</p>
<p>You have a process that creates a case record, but part of the process is to gather some information and use it to search for an existing customer record. If it&#8217;s found, a case is created and associated with the customer. But if there is no existing customer record, you want to use the captured information to create one, and then associate the case record with the new customer.</p>
<p>If you want to create a dialog for that business process, which entity should it be written for? Not so obvious, right? Phone Call might be a good candidate, but depending on your business requirements, it might be a little artificial to force a user to create a phone call activity simply to start the dialog!</p>
<p>Scenarios like this one come up a lot, and when they do, the right answer to the &#8220;which entity?&#8221; question might be that there really <em>isn&#8217;t </em>one. You might describe processes like this as &#8220;self-contained&#8221;. That is, the process itself gathers all of the information required to take the appropriate action, and there&#8217;s no need to start it from the context of a selected record.</p>
<p>Every process (workflow or dialog) requires an entity, however, so you have to select something! In situations like these the User entity is often the best choice.</p>
<p>Let&#8217;s illustrate these issues with an example. Suppose a process gathers information to create an opportunity record, but you also want the process to check whether a customer record already exists, and if not, create a new customer record before creating the opportunity. Heuristically, the flow looks like this:</p>
<ol>
<li>Gather basic contact information</li>
<li>
<div>Search for existing contact record</div>
<ol>
<li>
<div>If contact found</div>
<ol>
<li>Create new opportunity record, associate with existing contact record</li>
</ol>
</li>
<li>
<div>If contact not found</div>
<ol>
<li>Create new contact record</li>
<li>Create new opportunity record, associate with new contact record</li>
</ol>
</li>
</ol>
</li>
</ol>
<p>This is a good example of requirements for a self-contained process: unless the process is kicked off with a phone call (or some other record type) 100% of the time, it&#8217;s a forced fit to select one. What the user really wants in this situation is to &#8220;click a button and make it happen&#8221;! And while creating a dialog process against the User entity does not <em>automatically</em> provide this capability, it gets us pretty close.</p>
<p>We&#8217;ll examine a dialog process – Opportunity Intake – that has the following properties:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus1.png" alt="" /></p>
<p>For any reasonably complex process – and this one is in that category – you should follow some best practices; at a minimum, I&#8217;d recommend:</p>
<ul>
<li>Structure it in logical stages in the Step Editor.</li>
<li>Adopt a naming convention for process components like Response and Query labels, actions like Create Records and some others. This is an important topic and we will discuss it in detail elsewhere, but in this example you can see it in action.</li>
</ul>
<p>The next figure shows Stage 1. We start with page that gathers first and last names, and a Yes/No radio button prompt for whether to create a new opportunity record. As you will see below, this last prompt isn&#8217;t strictly necessary, but I included it in case we need to extend functionality later.</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus2.png" alt="" /></p>
<p>Next comes Stage 2, where things start to get interesting. It starts out with a query, which uses the first and last name values entered in Stage 1, and constructs a dynamic query to search for that contact. Next, the query results are tested to see whether any potential matches were located. If so, they are presented in a prompt and response, and the selected one is stored in the &#8220;Response: Selected Contact&#8221; variable. If not, then a second set of prompt and response pairs are presented on a different version of Page 2, and the response are then used to create a new contact record.</p>
<p> </p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus3.png" alt="" /></p>
<p>Perhaps the most interesting part of Stage 2 is the query that searches for existing contact records based on the first and last names gathered on Page 1. The query (shown in the next two figures, which you&#8217;d access by clicking <strong>Set Properties</strong> on the <strong>Query</strong> line) uses the trick discussed earlier in the book: on the Design New tab, enter placeholder values (e.g., &#8220;fistname&#8221; and &#8220;lastname&#8221;) in the query designer for the First Name and Last Name fields:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus4.png" alt="" /></p>
<p>Then, click the <strong>Modify Query Variables</strong> tab and use Dynamic Values to substitute in the Response Text from the <strong>Response: First Name</strong> and <strong>Response: Last Name</strong> variables. (If you work through an example like this you will start to appreciate the importance of a naming convention like the one I use here!)</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus5.png" alt="" /></p>
<p>One more thing about the query: notice the <strong>Operator</strong> is set to <strong>Like</strong>, rather than <strong>Equals</strong>. Refer back to the previous figure and notice the use of <strong>Contains</strong> rather than <strong>Equals</strong>. In a query like this you will almost certainly want the more forgiving <strong>Like</strong> operator, which corresponds to <strong>Contains</strong> in the Advanced Find UI.</p>
<p>Finally we get to Stage 3. If we don&#8217;t stop the dialog in the event the user responded No to the Create Opportunity? Prompt back in Stage 1, the Otherwise clause creates the new opportunity record. The only question is whether to attach it to an existing contact or to the new one created by the dialog, and we can apply the same checks here as before. This is shown in the next figure.</p>
<p> </p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus6.png" alt="" /></p>
<p>So, suppose you save and activate that dialog. Remember, it was created for the User entity, so you might think the only way to run it is to perform the following steps:</p>
<ol>
<li>In the site map, click <strong>Settings</strong>, and then click <strong>Administration</strong>.</li>
<li>
<div>Click <strong>Users</strong>, select the user to associate the dialog with, and in the <strong>Process</strong> section of the ribbon, click <strong>Start Dialog. </strong></div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus7.png" alt="" /></li>
<li>Select the dialog and click <strong>OK</strong> to kick it off.</li>
</ol>
<p>But if that&#8217;s all we can do, why is User any better than any other record type? Excellent question. Please proceed to the next section!</p>
<h3>URL-Addressable Forms</h3>
<p>Run a dialog – any dialog – and on the first page, press the Ctrl+N key combination to open a new Internet Explorer window. The following figure illustrates this in the context of the Opportunity Intake dialog:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus8.png" alt="" /></p>
<p>Notice that the URL is exposed in the new window&#8217;s address box. If you select the URL, copy it with Ctrl+C and paste it with Ctrl+V, here&#8217;s what it will look like:</p>
<p><a href="https://upb062811.crm.dynamics.com/cs/dialog/rundialog.aspx?DialogId=%7b95E011A1-FE9F-E011-86D6-1CC1DE798391%7d&amp;EntityName=systemuser&amp;ObjectId=%7bE113A45E-218C-4027-921D-B8F0100564C0%7d">https://acme062811.crm.dynamics.com/cs/dialog/rundialog.aspx?DialogId=%7b95E011A1-FE9F-E011-86D6-1CC1DE798391%7d&amp;EntityName=systemuser&amp;ObjectId=%7bE113A45E-218C-4027-921D-B8F0100564C0%7d</a></p>
<p>The format of this URL is important, as it&#8217;s defined by a feature of Dynamics CRM referred to as &#8220;URL-addressable forms&#8221;. This means that (almost) any form or window in Dynamics CRM can be accessed not only through the user-interface, but also directly, by its URL. To understand how you can exploit URL-addressable forms to customize the user experience, let&#8217;s break down this initially nasty looking example:</p>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup span="1">
<col style="width: 373px;" span="1"></col>
<col style="width: 361px;" span="1"></col>
</colgroup>
<tbody>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2">URL Component </td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Purpose </td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2"><a href="https://upb062811.crm.dynamics.com/cs/dialog/rundialog.aspx"><span style="font-family:Courier New; font-size:10pt">https://acme062811.crm.dynamics.com/cs/dialog/rundialog.aspx</span></a></td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Includes the organization URL, plus instructions to CRM to run a dialog process. </td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2"><span style="font-family:Courier New; font-size:10pt">?DialogId=%7b95E011A1-FE9F-E011-86D6-1CC1DE798391%7d</span> </td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Includes the GUID of the dialog to run.</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2"><span style="font-family:Courier New; font-size:10pt">&amp;EntityName=systemuser</span> </td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Includes instructions that the dialog is written for the User (systemuser) entity.</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt" colspan="2"><span style="font-family:Courier New; font-size:10pt">&amp;ObjectId=%7bE113A45E-218C-4027-921D-B8F0100564C0%7d</span> </td>
<td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt">Includes the GUID of the user for which the dialog should be run.</td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<p style="margin-left: 36pt"><em>Note: If you&#8217;ve ever wondered what those %7b and %7d things are in URLs like this, there&#8217;s an excellent explanation at www.w3schools.com , specifically: <a href="http://www.w3schools.com/TAGS/ref_urlencode.asp">http://www.w3schools.com/TAGS/ref_urlencode.asp</a><br />
</em></p>
<p style="margin-left: 36pt"><em>Basically, these are the URL-encoding characters for ASCII characters included in a URL. Since URLs often contain characters outside the ASCII set, these URL-encoding characters perform the conversion for us. Dynamics CRM commonly uses the &#8220;{&#8221; and &#8220;}&#8221; characters to enclose a GUID, so instead of {<span style="font-family:Courier New; font-size:10pt">E113A45E-218C-4027-921D-B8F0100564C0</span>}, a GUID inside a URL must be formatted like this: %<span style="font-family:Courier New; font-size:10pt">7bE113A45E-218C-4027-921D-B8F0100564C0%7d<br />
</span></em></p>
<p>So…where are we, then? A good, easy way to appreciate the utility of URL-addressable forms is to drag and drop the URL to your desktop, to create a shortcut:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus9.png" alt="" /></p>
<p>Finally, you can keep the shortcut in a folder with your other favorites:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_1441_BuildingBus10.png" alt="" /></p>
<p>Now if you&#8217;re thinking the approach I just described is a little bit hard-wired, you are correct: the URL just described will always run the dialog for the user referenced in the URL. That&#8217;s fine for the do-it-yourself shortcut trick, but what you will probably want to do is create a way for any user to &#8220;click a button&#8221; and run a dialog process as themselves – that is, for the current user. That takes a little bit of Jscript, and we will cover that next.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011-installment-5/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Building Business Processes in Dynamics CRM 2011: Installment 4</title>
		<link>http://www.dynamicscrmtrickbag.com/2011/06/27/building-business-processes-in-dynamics-crm-2011-installment-4/</link>
		<comments>http://www.dynamicscrmtrickbag.com/2011/06/27/building-business-processes-in-dynamics-crm-2011-installment-4/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 00:46:55 +0000</pubDate>
		<dc:creator>Richard Knudson</dc:creator>
				<category><![CDATA[CRM 2011]]></category>
		<category><![CDATA[CRM 2011 Business Process Book]]></category>
		<category><![CDATA[Dynamics CRM Workflows]]></category>

		<guid isPermaLink="false">http://www.dynamicscrmtrickbag.com/2011/06/27/building-business-processes-in-dynamics-crm-2011-installment-4/</guid>
		<description><![CDATA[June 27, 2011 - In Installment 4, I cover the important topic of how to query CRM data in CRM 2011 dialog processes. Cheers!]]></description>
			<content:encoded><![CDATA[<h2>Querying CRM Data</h2>
<table border="0" cellpadding="12">
<colgroup span="1">
<col span="1" valign="top" width="50%"></col>
</colgroup>
<tbody>
<tr>
<td><strong>June 27, 2011</strong> Dynamics CRM 2011 dialogs can query data from your CRM organization, and the data returned in a query can be used in prompts and responses. This important feature was briefly mentioned above but deserves a more detailed treatment.The most important topics covered here include basic query construction, how to construct dynamic queries, and how to structure your queries appropriately given the constraints of the dialog user experience (<em>hint: if you have 10,000 active accounts, don&#8217;t present them all in a dialog prompt of the Option Set (radio buttons) variety</em>!)</td>
<td style="text-align: left;" bgcolor="lightblue">This article is an excerpt from my upcoming book, <em><strong>Building Business Processes in Dynamics CRM 2011. Others in the series:  </p>
<p></strong></em></p>
<ul>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/20/building-business-processes-in-dynamics-crm-2011- installment-1/">Installment #1: Introduction to Dialog Processes</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/21/building-business-processes-in-dynamics-crm-2011- installment-2/">#2: Prompts and Responses in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/25/building-business-processes-in-dynamics-crm-2011- installment-3/">#3: Actions and Conditions in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/27/building-business-processes-in-dynamics-crm-2011- installment-4/">#4: Querying CRM Data in Dialogs</a></li>
<li><a href="http://www.dynamicscrmtrickbag.com/2011/06/28/building-business-processes-in-dynamics-crm-2011- installment-5/">#5 Calling Dialog Processes with a URL</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Now that we&#8217;ve discussed prompts and responses in more detail, consider again the following figure:</p>
<p style="text-align: justify"><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus1.png" alt="" /></p>
<p>Remember from above, this is the <strong>Response Details</strong> section from the Prompt and Response dialog. In the figure, the <strong>Query CRM data</strong> option is selected for the <strong>Provide Values</strong> setting, instead of the alternative <strong>Define Values</strong> option. These options are only available for the <strong>Option Set (picklist) </strong>and <strong>Option Set (radio buttons)</strong> response types.</p>
<p>With the <strong>Define Values</strong> option, you enter the options manually; use this option for situations when the values are <em>not</em> stored as records in a Dynamics CRM entity.</p>
<p>Use <strong>Query CRM data</strong> when the values are stored as CRM records. There are several advantages to using Query CRM data, including a couple of obvious ones:</p>
<ul>
<li>You won&#8217;t have to type as much.</li>
<li>Your dialogs will always reflect up to date data, without you having to manually update the values.</li>
</ul>
<p>Others are less obvious but perhaps more important. For example, you can create dynamic, or linked queries. These are where a user&#8217;s selection in query 1 is passed as input to query 2, making the second one dynamically dependent on the first.</p>
<p>Here are a few examples of how you might take advantage of the ability to query CRM data in a dialog process:</p>
<ul style="margin-left: 41pt">
<li>Suppose a process needs to prompt a user to select a contact associated with an account. A query can select the contacts associated with the account a dialog is running against, and present them to the user in a prompt. The user selects one, and a case record is associated with the selected contact.</li>
<li>A process might allow a manager to assign cases based on criteria such as time availability. A query might select users with no scheduled activities and present the list of users in a dialog prompt; the dialog could then assign a case to the selected user.</li>
<li>A process might allow a user to select from a list of e-mail templates, and use the selected template to send an appropriate follow-up e-mail to a contact. The list of e-mail templates could be created with a query in a dialog, with different criteria used to present templates appropriate for the business issue requiring follow-up.</li>
</ul>
<h3>Designing CRM Queries for Use in Dialog Processes</h3>
<p>The key to successfully using <strong>Query CRM data</strong> is designing your queries appropriately. Remember that the response types that can take advantage of this feature are the picklist and radio buttons options. These are not suitable for queries that return too much data, as you will see in the following simple example.</p>
<p>Suppose you have a dialog process a user can run from a Dynamics CRM Phone Call form. A scenario might be a receptionist receives a call, records the details with a phone call activity, and runs a dialog from the form to assist in creating a case, an opportunity, or some other record type. Let&#8217;s assume that you want to present the receptionist with a list of active accounts, and allow the selection of one, for which the record will be created.</p>
<p>We will present a more detailed step-by-step exercise shortly, but for now let&#8217;s take a high-level walk-through of how you&#8217;d build this and what it would look like.</p>
<ol>
<li>Create a new dialog process, name it &#8220;Phone Intake, Create Opportunity&#8221;, and base it on the Phone Call entity, and you will give you a process design form that looks like the following:</li>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus2.png" alt="" /></p>
<li>
<div>Now, click <strong>Add Step</strong> and select <strong>Query CRM data</strong>. The Step Editor will look like this:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus3.png" alt="" /></li>
<li>
<div>Click <strong>Set Properties</strong>, and the Define Query dialog will appear. This is the specialized version of Advanced Find you use to define the query that will provide the values to prompts presented later in the dialog. For this example, we will type &#8220;Active Accounts&#8221; in the Statement Label field, and select &#8220;Status Equals Active&#8221; in the query design section of the dialog:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus4.png" alt="" /></li>
<li>You can click <strong>Find</strong> to preview the query results, and then, as necessary, <strong>Back to Query</strong> to refine the query criteria.</li>
<li>
<div>Click <strong>Save and Close</strong>, and the Step Editor will look like this:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus5.png" alt="" /></li>
<li>
<div>For this example, all we will do is add a page with a single prompt and response pair. Click the <strong>Add Step</strong> drop-down and select <strong>Page.</strong> Then, click the indented line within the Page section, click the <strong>Add Step</strong> drop-down again, and this time select <strong>Prompt and Response</strong>:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus6.png" alt="" /></li>
<li>
<div>Click the <strong>Set Properties</strong> button to the right of Prompt and Response, and specify the following in the Define Prompt and Response dialog:</div>
<ol>
<li>Type <strong><em>Selected Account</em></strong> in the <strong>Statement Label</strong> field.</li>
<li>Type appropriate text in the <strong>Prompt Text</strong> field.</li>
<li>In the <strong>Response Type </strong>drop-down, select <strong>Option Set (picklist)</strong>.</li>
<li>In the <strong>Provide Values</strong> option, select <strong>Query CRM data.</strong></li>
<li>The <strong>Query Variables</strong> drop-down will then become active, and you can select the previously defined query, Active Accounts.</li>
<li>
<div>In the Columns section, select the <strong>Account Name</strong> column.</div>
<p> </p>
<p>After doing all this, you should see something along these lines:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus7.png" alt="" /></li>
</ol>
</li>
<li>Finally, click <strong>Save and Close</strong>, then <strong>Save and Close</strong> again. Activate the dialog process, and from a phone call form (make sure you save it first) you should be able to click Start Dialog in the Process section of the ribbon, and select the dialog process just created.</li>
</ol>
<p style="margin-left: 18pt">Results will vary depending on how many accounts you have in your CRM, but you can tell from looking at the following figure that picklist or radio button controls will not be a very good way to present this list to your users!</p>
<p style="margin-left: 18pt"><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus8.png" alt="" /></p>
<p>The controls we have to work with in dialog processes are drop-down lists and radio buttons, not lookups, so you will need to design queries that don&#8217;t return hundreds of records. I&#8217;ll spare you the radio buttons version of this, but believe me, it&#8217;s even worse!</p>
<p><em>So…how many records are too many?<br />
</em></p>
<p>Well, you cannot display more than a single page of records in a dialog prompt, and since you cannot have more than two-hundred fifty records on a single page, a dialog prompt that breaks the 250 records barrier will not allow a user to select from all the available records. The <em>minimum</em> setting for <strong>Records Per Page</strong> is twenty-five, so if you go higher than that, there may be a few of your users who will need instructions on how to increase. On the other hand, the default setting is fifty, and a picklist with more than 25 options isn&#8217;t all that unmanageable, so I&#8217;d propose fifty or so as an upper bound for the number of records to return in a query designed for this purpose.</p>
<p>Fortunately, there are plenty of approaches you can use to optimize queries for use in Dynamics CRM 2011 dialog processes. I&#8217;ll review a couple of my favorite here, and then throughout the rest of the book we&#8217;ll examine others in context.</p>
<li>
<h4>Example: Filter a Query by the Current Record</h4>
<p>Every dialog runs against a single record. At the risk of emphasizing the obvious, this is the record you have selected when the dialog is started. You can select a record on a data grid and click <strong>Start Dialog</strong> on the ribbon, or open a form and do it from there. In the workflows section of the book, we discussed in some detail how dynamic values can be used when designing a business process. For example, as an instance of a workflow runs against a record, it can access any of the field values for that record, plus any of the field values for any records with a 1:N relationship to the record.</p>
<p>Although there are many differences between workflow and dialog processes, there are plenty of similarities as well, and this is an important one: the business process run-time engine works the same with respect to CRM data for dialogs as it does for workflows.</p>
<p>So how can you exploit dynamic values and data relationships as you construct dialog queries? Let&#8217;s revisit the Create Case for Account dialog we discussed previously for a good example of this. Suppose we want to modify the dialog so that in addition to prompting a user for basic information to be used to create a case for an account, it also presents a list of contacts associated with the account, and associates the selected contact as the &#8220;responsible contact&#8221; for the case record. Here are some of the important issues this new requirement raises:</li>
<ul style="margin-left: 38pt">
<li>Since the dialog is written with Account as its primary entity, we can use the current account as a filter for a query of contact records. For many organizations, the number of contacts per account is small enough that it won&#8217;t violate the &#8220;fifty or so&#8221; record count limit proposed earlier.</li>
<li>The mechanics of constructing a query like this one take a little getting used to.</li>
<li>We need a way of checking the number of contacts associated with the current account record; and in particular, if there <em>are</em> some, we need to prompt the user to select one and then update the case record. If there <em>no</em> associated contacts, we don&#8217;t want to do those things. Sounds like some conditional logic in the dialog, right?</li>
</ul>
<p>The following figure shows what a dialog like this might look like in the Step Editor. Although it&#8217;s not required, this one is presented in stages to make it easier to understand:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus9.png" alt="" /></p>
<p>Here&#8217;s an overview of each stage:</p>
<ul>
<li><strong>Stage 1</strong> is essentially the same as the previous example. The Page is collapsed to save space, but it does the same thing as before: Prompt/Response pairs for the basic information needed to create a case record.</li>
<li><strong>Stage 2</strong> is where the query is constructed by passing the value of the current account record in as a filter to a query for contacts. This is new territory and is presented in detail next.</li>
<li><strong>Stage 3</strong> performs a conditional check to see if the account has any associated contacts. Only if there are some will the dialog prompt the user to select one of them; and only in that case will the dialog update the previously created case record with the responsible contact.</li>
</ul>
<p>The following figure shows what a query looks like when values are substituted into it at run time. This is the finished product of Stage 2 above; notice the Statement Label field is <strong><em>Contacts for Account</em></strong>, which you can also see as the label for the <strong>Query</strong> step in the previous figure.</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus10.png" alt="" /></p>
<p>If you haven&#8217;t done this before, you might not even realize there&#8217;s a <strong>Modify Query Variables</strong> tab you can use to substitute dynamic values into a query, but here it is. Notice the highlighted areas: the Account lookup field (schema name <strong>parentcustomerid</strong>) is passed, via the <strong>Variable1</strong> variable, into the FetchXML statement. The tricky part is getting that yellow-highlighted <span style="background-color:yellow">Account(Account)</span> dynamic value into Variable1, so here&#8217;s a step-by-step exercise to walk you through it.</p>
<p><span style="font-family:Cambria"><strong>Step by Step: Build a Dynamic Query<br />
</strong></span></p>
<p>Assume for the moment that you&#8217;ve created the previous dialog up through Stage 1: that is, you&#8217;ve gathered the basic/required information in a series of prompts and responses in a single page, and have created the case record. Now it&#8217;s time to create the query for contacts at the current account, so position the cursor just outside of the Page block, and follow these steps:</p>
<ol>
<li>Click <strong>Add Step</strong>, and select <strong>Query CRM Data</strong>.</li>
<li>Type Contacts for Account in the Statement Label field, and select Contacts in the Look for drop-down.</li>
<li>On the query designer, click <strong>Select</strong>, then scroll down to the <strong>Parent Customer</strong> field and select it.</li>
<li>Press the tab key, accept the default operator of <strong>Equals</strong>, and tab again into the lookup field.</li>
<li>
<div>Click the lookup button, and <em>select any value you like</em>. I know this seems odd at first, but you need to provide a placeholder here, otherwise you won&#8217;t be able to perform the all-important next steps. It should look something like this:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus11.png" alt="" /></li>
<li>
<div>Now, click the <strong>Modify Query Variables</strong> tab and you will see this:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus12.png" alt="" /></li>
<li>
<div>Here&#8217;s where the dynamic values part comes in: position the cursor in the <strong>Variable1</strong> field in the XML Values section, and then make sure <strong>Account</strong> is selected in both drop-down lists underneath <strong>Look for</strong> in the <strong>Dynamic Values</strong> section. It looks odd, but the first Account refers to the entity, the second to the Account lookup field. Click <strong>Add</strong>, and then click <strong>OK</strong>, and you will see this:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus13.png" alt="" /></li>
<li>Click <strong>Save and Close</strong> and you&#8217;ve created the dynamic query.</li>
</ol>
<p>Another thing about that takes some getting used to: once you&#8217;ve used this <strong>Modify Query Variables</strong> tab to substitute a variable into the FetchXML, you cannot go back to the Design New tab. (If you click it, you&#8217;ll get a warning that your work will be lost. Which it will, so don&#8217;t do it unless you need more practice.)</p>
<p>That gets you through Stage 2 of this dialog; on to Stage 3. Refer back to the dialog overview figure above and focus on the most important thing in Stage 3, the <strong>If</strong> condition. This is an example of a topic I covered previously, in the section <strong><em>Specifying Conditions in Dialogs</em></strong>. And while the example is specific, the concept is a general one: when you construct a dynamic query, how do you know how many records will be returned? If too many are returned, you run the risk of violating the &#8220;fifty or so records max&#8221; rule of thumb discussed earlier. If too few records are returned, it gets worse, especially if there are no records returned.</p>
<p>The Create Case for Account example shown above already has logic built into it to manage this problem, but suppose it did not. For example, suppose you were just learning how to build Dynamics CRM 2011 dialog processes and didn&#8217;t know about these things yet. You might build a dialog like the following one:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus14.png" alt="" /></p>
<p>If you compare the two versions of the dialog, you&#8217;ll notice that this one does not include any conditional logic in Stage 3. You might be able to guess what happens if you save and close it, activate it, and run it. If the account it runs against has associated contacts, it works fine, but if not, you see the following:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus15.png" alt="" /></p>
<p>Notice that the Next button is grayed out, so you can&#8217;t even complete it! In this example, the problem is that a dialog prompt cannot be displayed without any options, and since the options here are provided by a query that returns no data, the dialog cannot proceed. And that&#8217;s why the special Records variable was created: so we can test how many records exist, and take appropriate action.</p>
<p>So how do you go about fixing a problem like this? Let&#8217;s continue our example by fixing the current broken version of the Create Case for Account dialog, starting here, in the Step Editor, with the cursor positioned on the single Page in Stage 3:</p>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus16.png" alt="" /></p>
<p>This is a real-world example, where you&#8217;re fixing something that&#8217;s broke, so to speak, so while you might not always take an approach like the one I do here…it&#8217;s worth seeing it, just in case.</p>
<p><span style="font-family:Cambria"><strong>Step by Step: Build a Condition to Check Record Count<br />
</strong></span></p>
<ol>
<li>Click the <strong>Insert</strong> drop-down, and select <strong>Before Step</strong>.</li>
<li>
<div>Click <strong>Add Step</strong>, and select <strong>Check Condition</strong>.</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus17.png" alt="" /></p>
<p>Notice that the If condition went before the Page, which in this case is what we want.</p>
<p> </li>
<li>Click <span style="color:#0070c0"><strong>&lt;condition&gt; (click to configure)</strong></span>, and the <strong>Specify Condition</strong> dialog will open.</li>
<li>
<div>Click Select to access the drop-down list in the first column, and select the query, which will be in the Local Values section:<br />
<img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus18.png" alt="" /></div>
<p>Notice that in this version of the dialog, I&#8217;ve prefaced the query with the text &#8220;Query: &#8220;, to make it easier to find. This is part of a naming convention I will propose a little later in the book.</li>
<li>After selecting the query, tab to the second column in the dialog, and select the only available option, <strong>Records</strong>.</li>
<li>
<div>Then tab to the third column and notice the available operators are the standard ones you see in Advanced Find when filtering on integer fields. This makes sense, because that&#8217;s the data type of the special Records field you just selected. Select <strong>Equals</strong> and tab to the value field in the next column.</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus19.png" alt="" /></li>
<li>
<div>Enter 0 in the value field, and click <strong>Save and Close</strong> to return to the Step Editor:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus20.png" alt="" /></li>
<li>
<div>Click the <strong>Select this row and click Add Step</strong> line and click Add Step. Select the <strong>Stop Dialog</strong> action. That&#8217;s all you really need to do, but consider adding some descriptive text, after which your Stage 3 might look like this:</div>
<p><img src="http://www.dynamicscrmtrickbag.com/wp-content/uploads/2011/06/062811_0046_BuildingBus21.png" alt="" /></p>
<p>If you save and close, activate, and then run this dialog process, it will work fine regardless of whether the selected account has associated contacts or not:</li>
</ol>
<ul style="margin-left: 72pt">
<li>If there are no contact records, the condition evaluates to true, and the Stop dialog action is executed.</li>
<li>If there are contact records, the condition evaluates to false, the Stop dialog action is skipped, and the dialog continues to the Page step, which displays the prompt and then updates the Case record with the selected contact.</li>
</ul>
<p>Again: while this works, it&#8217;s not necessarily the best way to write a process like this! It depends on what else you need to do, but in general I&#8217;d say that the approach presented at the beginning of this section (with the If condition flipped (record count &gt;= 1), and the Page and Update Case actions <em>inside</em> the If clause) is a little easier to read, and sometimes has other advantages as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dynamicscrmtrickbag.com/2011/06/27/building-business-processes-in-dynamics-crm-2011-installment-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

