Related sites:

Newsletter: Perspectives on Power Platform

Company: Niiranen Advisory Oy

Address Copy Button with CRM 2013 Business Rules and Workflows

The default forms in Dynamics CRM only contain one set of address fields, but most organizations will need to surface at least the Address 2 fields for accounts and contacts to manage the different information for visiting address, mailing address, delivery address, invoicing address or whatever the business scenario.

Sometimes it may be justified to have a bit of redundant information in your CRM database for practical purposes. For example, if you use the Address 2 fields for managing the mailing addresses for accounts where this is separate from the visiting address, it may be easier to have the mailing address fields populated also in scenarios where the values are identical to the visiting address. Otherwise the marketing assistant who is building target groups for mailing campaigns will need to perform some Excel sorcery to pick different address fields for different customers when extracting the data from CRM.

If you’ve bought anything from online stores during the past 10 years, you’ve probably ran into a nice little feature on the checkout or registration forms where the system asks if you’d like to use the address information you entered into your customer profile also as the shipping address for the order. Often times this is presented as a checkbox field that you simply need to tick once, to save you the trouble of re-entering the same data the system already knows.

Wouldn’t this be a nice feature to have also on the CRM account form? Let’s take a look at a form where both Address 1 and Address 2 fields are presented side-by-side. If we would have a “Copy to Address 2?” checkbox that the user could tick after having tabbed through the Address 1 fields and entering data into them, that would be quite an intuitive feature that the users would surely feel right at home with. On the account form it could look like this:

CRM_2013_address_copy_account_1

Now that we have our new custom field below the Address 1 fields, next we need to build the functionality for duplicating the field values from Address 1 to Address 2. So, please open you “Javascript for Dummies” textbook from page 47 and… Hey, wait a minute! We’re working with CRM 2013 now that has the great new Business Rules feature for situations like these! Forget what I said about scripts, instead go ahead to the account entity customization menus and add a new Business Rule for this form.

On the “Copy Address 1 to Address 2” Business Rule we’ll set a single condition to monitor the value of our custom chechbox field. If the box is ticked, meaning the field value equals “Yes”, we’ll set the values of each visible Address 2 field on the form to be the same as what’s been entered into the corresponding Address 1 field.

CRM_2013_address_copy_business_rule

Once we publish our customizations and activate the Business Rule, we can try out the feature in practice. Let’s create a brand new account record to simulate the typical data entry process (although an existing account would work just as well). After we’ve entered the Address 1 information on the left column, the moment we tick on the “Copy to Address 2?” box we’ll see the address fields on the right side get populated with the same values in real time.

CRM_2013_address_copy_account_2

Great, we’re all set to move this into production now! Or are we actually? What happens when the user wants to go and edit the field values for Address 2? If we leave the “Copy to Address 2” box ticked, then our Business Rule will keep copying the values over to the Address 2 fields the next time the rule is evaluated. As we’d like to allow the user to leverage this copy feature to initially replicate the fields to Address 2 but perform the necessary changes to those values that are in fact different, such as editing the Street 2 field, we should somehow restrict when our field copy operation is triggered.

One option would be to just add one more Action into our Business Rule, whereby we would set the “Copy to Address 2” field back to “No” again. One problem I see with the user experience in this approach is that since the rule runs immediately when the user ticks the box, the UI will not give a clear indication that the event was completed successfully. Sure the values get transferred, but when working with an existing account this may not be so obvious. We could present an error message through the Business Rule action, but no one likes to see a rec error icon after a successful operation.

Instead of a Business Rule that runs on the client side immediately, what we can do is to create a Real-Time Workflow rule that is run on the server side the moment that the data is submitted to the database. In the “Clear Address Copy Tickbox” rule below we’ll set the rule to be run synchronously (i.e. real-time) and attach it to the record creation event and also the field change event of the “Copy to Address 2” field. In the conditions we’ll check whether the field is currently set to “Yes” and if so, we’ll simply set the same field back to “No”.

CRM_2013_address_copy_workflow

After we activate our workflow and try the same process steps again, we’ll now see that after the account record is created or the updated address values are saved, the Copy field gets cleared automatically:

CRM_2013_address_copy_account_3

Now the user is free to go and change the Address 2 fields without having to worry about the values being overwritten with Address 1 fields every time he or she re-opens the record. If the user ever wants to repeat the Copy process, checking the box will transfer the current Address 1 values to Address 2 again.

CRM_2013_address_copy_account_4

Pretty cool, don’t you agree? Writing custom code for simple field manipulation tasks is soooo CRM 2011, now that the Business Rules and Real-time Workflows allow us to develop no-code process automation features. Extending the conditional logic of workflows to the client side where the presentation of the form and data can be change immediately after the user’s input gives us a great new toolkit for tailoring the CRM application user experience to be much more responsive, by minimizing the need for duplicate data entry and showing only the most relevant information at any given time.

As these platform features get develop further in future releases of Dynamics CRM, I believe we’ll be able to move beyond the basic question of “what data do we need to manage with CRM” and focus more of our efforts on “how should this data be presented” and ultimately “how will the users interact with the data”. Starting from the current system’s most common use cases, analyzing the user actions included in them and investigating whether they contain any potential scenarios that the CRM 2013 Business Rules features could help in streamlining is a great way to start the journey on this path towards a CRM system that your users can really love to use.

11 Comments

  1. Hi Jukka,

    Great post! I was trying the same thing last week but with two real-time workflows. I think using the Rules is better indeed. I had a different musing all together though. Is it not better to uncheck the ”Copy to Address 2″ field ony when a user changes on of the fields of address 2.

    I tried it and the workflow changes the checkbox before the rules is fired. My only concern is that maybe it affects performance because the rule is always true until a user changes address him/her self.

    What do you think?

    • Thanks for your comment, Eyup! You could definitely implement the copy functionality through many different ways. Ultimately I think these are the kinds of actions that the user would expect to take place immediately on the form (as they do on common websites), so even a real-time workflow will always introduce a delay there. Since address entry is often performed while initially creating the record, it will be up to the user’s clicking of the save button for the rule to fire. If it’s an update, then it will be either the 1-30 second auto-save interval or a manual save. With Business Rules the user experience is always consistent: you tick a box and then the address fields get updated.

      As for clearing the box upon changes of Address 2 fields, this is a good idea and worth exploring. My reasoning behind removing the tick from the box at the first save was to simulate the behavior of a form button while still showing some indicator to the user that the control which he or she has clicked (the “Copy to Address 2?” checkbox) has acknowledged the event that the user performed. Removing it right away with the same Business Rule would be possible, but as mentioned in the post, I didn’t like the fact that this appears as a “tick that doesn’t stick”.

      Waiting until one of the Address 2 fields is not equal to the corresponding Address 1 field while the Copy field is ticked shouldn’t impose any significant performance problems according to my understanding, since these are just client side rules that are evaluated on the form load or field change events. They don’t actually sit in the database waiting for the conditions to be met, like asynchronous workflow rules would. Having said that, I don’t have any real-life experience of having tens of Business Rules active on an entity form and the performance impact of those. They probably won’t be as optimized as bespoke Javascripts, so testing how the rules affect page load times would be a good idea.

  2. Hello,

    I found this very helpful but what if the user wants to clear the copied address fields?

    So I have address1 fields as my primary. I then created the field “copy address” and implemented the business rule to copy the values to address 2 fields. Great….but the user clicked it out of habit and didn’t really want the address fields copied. So I implemented a clear values business rule only not so elegant.

    The clear rule doesn’t accept (I couldn’t figure it out) empty values. I Googled for keywords that would work but nada. So I finally created another field called EmptyString and when the user selects to clear addy 2 fields in my business rule action I set the field value the the value of the field emptystring.

    Well this isn’t working either. If emptystring doesn’t get set I wonder if it is null as opposed to blank (ie no text)

    Ultimately my question is how do you clear a field….any field. I can see myself wanting to do this in other Business Rules???

    Thank You

    • Thanks for sharing the workaround you’ve discovered, Ramjet. The Business Rules in CRM 2013 currently have a limitation that doesn’t allow clearing the value of a field. This has also stopped me from implementing many usability improvement scenarios that would otherwise be a perfect fit to be implemented via no-code Business Rules, so I hope this feature is enhanced in future releases of Dynamics CRM. I encourage everyone to go to MS Connect and vote on this item to help it make it to the lest of features for the CRM product team to develop: CRM 2013 – ability to set field value to NULL in Business Rules.

  3. Another variation that I liked better than the workflow (personal preference) is in your Biz Rule AFTER setting the addy 2 fields set your copy address tick back to No. The addy copies and the tick clears instantly. No overhead of a workflow and hooked events. Almost looks more like a button click.

    • Ramjet, that is indeed a possibility that I tested out myself, but didn’t find the user experience to be intuitive enough. It results in an “untickable” box, as the tick is never displayed to the user. While the address fields do get updated, is it going to be obvious to the user that the operation completed successfully (especially if the fields weren’t blank to start with)? Ultimately this feature should be shown as a real button instead of a field, but that approach will require some custom code. We can already replicate the data update functionality with Business Rules, but UI manipulation via them is currently somewhat limited for this type of scenarios.

  4. I tried this solution, but when I created the Real-time Workflow, I don’t see my “copy to address 2” field. I see it when I choose Record Field Change and when I do my check condition to see if the field is set to yes…but when I go to Update the record, the form that displays, doesn’t show my “copy to address 2” field so I can set it back to No??

    What am I missing?

  5. Have noticed that if you click on Copy checkbox immediately after entering the fields, the data may not copy. When I say immediately, I am talking ‘lightning speed’. To test it, just enter a single letter in any address field and then IMMEDIATELY click on Copy checkbox. This value will not copy in the corresponding field on the other address section.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.