CRM 2011 – Javascript case statement

I had to write some code where I had a lot of checkboxes and when a user selected a value on a dropdown then some would be shown and the rest would be hidden.

To do this I created 6 sections and placed the checkboxes in the correct section.  When the user changed the dropdown I then displayed one of the sections and hide the others.  This saved me writing the visible functionality for all the checkboxes (and there were loads – 60 plus).

Below is the Javascript which first reads the drop down and then based on the value it then displays a section and hides another.  The real code had 6 sections which is why I used a switch statement rather than lots of IF and IFElse statements.


var mainJobType = Xrm.Page.getAttribute("meta_generaljobtype").getText();

 switch (mainJobType) {
 case "Internal Works":
      Xrm.Page.ui.tabs.get("general").sections.get("InternalWorks").setVisible(true);
      Xrm.Page.ui.tabs.get("general").sections.get("ExternalWorks").setVisible(false);
 break;
 case "External Works":
      Xrm.Page.ui.tabs.get("general").sections.get("ExternalWorks").setVisible(true);
      Xrm.Page.ui.tabs.get("general").sections.get("InternalWorks").setVisible(false);
 break;
 default:
      Xrm.Page.ui.tabs.get("general").sections.get("InternalWorks").setVisible(false);
      Xrm.Page.ui.tabs.get("general").sections.get("ExternalWorks").setVisible(false);

 }

CRM 2011 – International Address Validation Now Available on Microsoft Dynamics CRM at a cost

I saw this tweet today Martin ten Voorde saying address validation is now available in CRM 2011.  Hazaar I thought, Postcode Anywhere, hmmm I have heard of them, this is looking very good.

The solution is available on pinpoint which you can find by clicking the link below, although I will say ITS NOT FREE before anyone gets too excited.

http://dynamics.pinpoint.microsoft.com/en-GB/applications/uk-postcode-lookup-and-international-address-verification-12884934715

here is a screen shot

if you want to find more about the pricing in detail then click the link below

http://www.postcodeanywhere.co.uk/integrations/microsoft-dynamics-crm/pricing/

I shall copy a few bits and bobs to give you a rough idea of the price.  It doesn’t seem that much and if it’s something a customer wants then this could be an easy way to implement postcode searching and date validation