CRM 2011 - Workflows Vs JavaScripts

Posted by Kanini on Programmers See other posts from Programmers or by Kanini
Published on 2013-03-04T16:51:36Z Indexed on 2013/11/07 4:13 UTC
Read the original article Hit count: 566

Filed under:

In the Contact entity, I have the following attributes

Preferred email - A read only field of type Email
Personal email 1 - An email field
Personal email 2 - An email field
Work email 1 - An email field
Work email 2 - An email field
School email - An email field
Other email - An email field
Preferred email option - An option set with the following values
  {Personal email 1, Personal email 2, Work email 1, Work email 2,
   School email and Other email). 

None of the above mentioned fields are required.


When user picks a value from Preferred email option, we copy the email address available in that field and apply the same in the Preferred email field.


The Solution Architect suggested that we implement the above requirement as a Workflow. The reason he provided was - most of the times, these values are to be populated by an external website and the data is then fed into CRM 2011 system. So, when they update Preferred email option via a Web Service call to CRM, the WF will run and updated the Preferred email field.

My argument / solution

  • What will happen if I do not pick a value from the Preferred email Option Set? Do I set it to any of the email addresses that has a value in it? If so, what if there is more than one of the email address fields are populated, i.e., what if Personal email 1 and Work email 1 is populated but no value is picked in the Option Set?
  • What if a value existed in the Preferred email Option Set and I then change it to NULL?
  • Should the field Preferred email (where the text value of email address is stored) be set to Read Only?

    • If not, what if I have picked Personal email 1 in the Option Set and then edit the Preferred email address text field with a completely new email address
    • If yes, then we are enforcing that the preferred email should be one among Personal email 1, Personal email 2, Work email 1, Work email 2, School email or Other email [My preference would be this]
  • What if I had a value of [email protected] in the personal email 1 field and personal email 2 is empty and choose value of Personal email 1 in the drop down for Preferred email (this will set the Preferred email field to [email protected]) and later, I change the value to Personal email 2 in the Preferred email. It overwrites a valid email address with nothing. I agree that it would be highly unlikely that a user will pick Preferred email as Personal email 2 and not have a value in it but nevertheless it is a possible scenario, isn’t it?

  • What if users typed in a value in Personal email 1 but by mistake picked Personal email 2 in the option set and Personal email 2 field had no value in it.


  1. The field Preferred email option should be a required field
  2. A JS should run whenever Preferred email option is changed. That JS function should set the relevant email field as required (based on the option chosen) and another JS function should be called (see step 3).
  3. A JS function should update the value of Preferred email with the value in the email field (as picked in the option set).
  4. The JS function should also be run every time someone updates the actual email field which is chosen in the option set.

The guys who are managing the external website should update the Preferred email field - surely, if they can update Preferred email option via a Web Service call, it is easy enough to update the Preferred email right?


Which is a better method? Should it be written as a JS or a WorkFlow?
Also, whose responsibility is it to update the Preferred email field when the data flows from an external website?

I am new to CRM 2011 but have around 6 years of experience as a CRM consultant (with other products). I do not come from a development background as I started off as a Application Support Engineer but have picked up development in the last couple of years.

© Programmers or respective owner

Related posts about how-to