How to concatenate two fields using workflow in Dynamics CRM 2011:

Topics to write about that will provide value seem to elude me at times.  In trying to provide value to my readers without the use of custom code in Microsoft CRM can sometime provide trying.  Here is a tip that I have found most do not know if possible using workflow.

Ever have two fields in a record and want to have both values automatically fill into a third field?  Did you know that was possible using CRM 2011 Workflow, (actually this is something you could have accomplished using CRM V4.0 or V3.0 also).

Let’s look at the business process first.

Scenario – You are a consultant for XYZ Company and your client would like to combine the last name field along with the business phone of the contact in order produce a  unique customer number.  How would you proceed?

Solution – Use workflow to complete the task.  One possible no code solution is represented below.

A bit of housekeeping; first let’s create the CustomerID field in CRM.  Go to Settings, Customizations; Customize the System, Entities, Contact, Fields, and click on the New Field button.  Since this is going to be a combination of Characters and Numbers we will use the single line of text option for the field type.

We will then add the field to the form.  Save and Publish.

Open your CRM Organization.  Go to settings, processes and click on the new button.

Name the process.  Since we are working with the Contact entity, chose it from the dropdown entity list, and classify this process category as workflow.  Click the ok button.

I always like to make all process on demand until I have debugged it.  In addition, since this process is going to be used by everyone in the company I will change the scope to organization.  Finally for the sake of this example, I will only use the trigger when a new record is created option.  (We can actually use the when record fields change option also in a more complex situation, for example, if there is no business phone number on create of the new record and eventually one is added we might want to generate the unique ID at that point of time.)  Now it is time to start adding steps to this process.

Our first step is to modify the CustomerID field with the Last name of the Contact.  So we will use the update step and choose the Contact Entity to update. We will plug the CustomerID with the last name.

Click on OK; your modify step should look as follows.  Click on save and close.

Next we will add another modify entity step and again choose the Contact entity.  This time we are going to use the operator called Append With.  (Using the Append With will add to any value already present in the field.)  For this example we want a “-“ in between the last name and phone number so we will add it to the CustomerID field.  In the form assistant we will choose the Business phone and click on ok.

The second update step should look as follows, (notice above the CustomerID field the “Append With” tag is present.

Note – In my example I wanted to make sure the customer ID process workflow would only update the CustomerID field under the following conditions; there is an entry in both the Last Name and Business Phone fields, in addition, if there is already a value in the CustomerID field I do not want the process to complete successfully.  (These steps are optional.) 

My workflow looks as follows prior to activation:

Now I want to manually test the workflow using the on demand option, or the Run workflow button from the contact record.

We can monitor the progress by clicking on the Workflow Tab under processes from the left navigation Window.

When the process completes as succeeded we can refresh the contact record, (either by clicking on F5 or close the record and reopen), to view the final results.

Our update and append works properly!

At this point there are a few items of housekeeping I usually want to accomplish.  Since this is a unique value I usually do not want anyone changing that value once it is generated.  The easiest way to accomplish this it to make the attribute CustomerID read only after the workflow has been created.  Please note – If you change the attribute properties to “Read Only” prior to completing the workflow you will not be able to use the attribute within the update process.  Therefor Rules Of Thumb, create the workflow, test, and then make the attribute “Read Only” after the testing is complete.

Finally I would un-publish the workflow and take away the on demand option as well as adding steps to stop the workflow after each “IF” statement as unsuccessful or successful if the workflow completes as expected.

From this point I would republish the workflow.

At this point I am sure to hear from all the developers a laugh, “I can do the same thing easier with Jscript on the attributes”.

Sure you can, and there are other methods in addition for accomplishing this same task.  This article was written for the business users who do not know how to write code and would like to configure CRM to suit their needs.

I hope this helps that audience.

Happy CRM’ing!

Steven

About Steven Jacobowitz

An innovative transformative leader, driving organizational profitability. Creating a culture where mistakes are embraced as learning experiences. Together, let's forge a future of balanced growth and client satisfaction.
This entry was posted in CRM Configuration, CRM Workflow. Bookmark the permalink.

10 Responses to How to concatenate two fields using workflow in Dynamics CRM 2011:

  1. Pingback: Microsoft CRM 2015 New Feature – Drilling into Calculated Fields- The String Functions – Part 2 | C/xRM Ramblings

  2. Pingback: Microsoft CRM 2015 How Do I Concatenate Two Fields In Microsoft CRM 2015? Revised | C/xRM Ramblings

  3. Steve says:

    Thanks that was a big help! Doesn’t seem intuitive to Set to and then Append with, but makes sense now 🙂

  4. Lamar says:

    Very shortly this website will be famous amid all blogging and site-building visitors, due to it’s pleasant posts

  5. Mike says:

    Will it still work the same if your custom attribute field is in the header? In the header section all the fields are read only.

    • Before writing the workflow remove the read only constraint from the target attribute. Once you have completed add the constraint back on to the attribute. The workflow will then work. I hope this helps you! Steven

  6. Bob says:

    Thanks, Steven. You just made my day!

  7. Richard says:

    This is a really great tutorial. Do you know if there’s a way to append a field in a multi-line text box on new a new line. i.e. is there a way to insert a carriage return after the dynamic field?

Leave a comment