Archive for January 2010

CRM 5 & Windows Azure Video - Looking Good MS!

A fellow CRM Guru found this great video which shows windows azzure but also previews a lot of nice features in CRM 5.0 including things like Nested Grids, Visualizations and Dashboards. The new ribbon looks fantastic too!


It gets interesting from about 5 minutes in..


Click Here To Watch The Video


Cheers


Joel
Monday 11 January 2010
Posted by XRM Consultant

Dynamics CRM 4.0 - Reference Picklist Values With Values Over 200,000 in JavaScript

Hi, 


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
crmForm.all.tab4Tab.style.display = "none";
}


else {
//show the second tab
crmForm.all.tab4Tab.style.display = "";


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
crmForm.all.tab4Tab.style.display = "none";
}


else {
//show the second tab
crmForm.all.tab4Tab.style.display = "";


Hope this helps a little. 


Cheers


Joel

Posted by XRM Consultant

Search This Blog

Popular Post

About xRM Consultant.com

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 -