Posted by : XRM Consultant Monday, 11 January 2010


Recently a fellow CRM guru was having some trouble with hiding a tab based on a picklist value. Its a simple piece of code:

//Hide Or Show Display Options Tab
if (crmForm.all."nameofyourpicklistattribute".DataValue == 2)
//hide the second tab = "none";

else {
//show the second tab = "";

However, its wasn't working. The JavaScript was correct and the field references were also correct. 

The problem lies in that the value for the picklist item was 200,014! Now, why on earth was the picklist value so high? Especially when there was only about 20 items in the list?

It comes from a new feature added to CRM 4.0. The best explanation i have heard of the issue was given by Michael Höhne on another blog site:

"It's a new feature. CRM 3.0 did not allow changing the integer value which
caused a lot of unwanted trouble. Say you added a new picklist to the
account and contact and also added a field mapping. You continue to add new
values and remove some options. At some time you notice that the picklist
values are out of sync. Having the option to overwrite the integer values
ensures that you can fix this issue. However, it does not change existing
values in the database, so it should be used carefully.

Michael Höhne, Microsoft Dynamics CRM MVP"

The problem this created was that for some reason JavaScript was not recognizing the value when executing the script. It would run, without bringing up an error but just wouldn't do anything! Personally, i believe this is because the comma (200,014) throws it off. 

So, taking a different approach, we referenced the text value of the option we were looking for and it works perfectly. So the JavaScript is now:

//Hide Or Show Display Options Tab
if (crmForm.all."nameofyourpicklistattribute".SelectedText == "text of your picklist item")
//hide the second tab = "none";

else {
//show the second tab = "";

Hope this helps a little. 



Leave a Reply

Subscribe to Posts | Subscribe to Comments

Search This Blog

Popular Post

About xRM

Having worked with Microsoft Dynamics CRM 4.0 in a sales & development environment, my focus now is on customising this awesome solution and showing its true potential.
Powered by Blogger.

- Copyright © xRM Consultant -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -