CRM 2011 – Javascript Xrm.Page Basics

Posted on February 17, 2011


I have been looking at the CRM 2011 Javascript SDK, samples. Comparing it to CRM 4 code and getting very angry.  It just wasn’t the same and I wasn’t understanding the SDK, it was written in an odd way and the examples were just much more complex than I needed to get started.  I have also written a good blog entry about the comparison between Javascript CRM 2011 and CRM 4

I could hide sections and tabs ok, using the Page ui but setting variables was really starting to bug me. I could get it too work using crmForm but I wanted to move on and use the new code.

I think the problem is highlighted looking at the new Javascript layout

The UI bit makes sense but looking at this I couldn’t see how to get the actual fields!!!

there is also a big difference with the actual Javascript you write everything has to get something



once you get the variable you can then getValue or setValue

Xrm.Page.getAttribute(“hosk_display2″).setValue(“HOSK SET THIS CRM 2011 STYLE”);


JavaScript CRM 4 to CRM 2011 converter tool:

and looking at these tidbits at this blog

Here are common tidbits:

Get the value from a CRM field

var varMyValue = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getValue() ;

Set the value of a CRM field

Xrm.Page.getAttribute(“po_CRMFieldSchemaName”).setValue(‘My New Value’);

Hide/Show a tab/section



Call the onchange event of a field


Get the selected value of picklist


Set the requirement level


Set the focus to a field


Stop an on save event
event.returnValue = false;

Return array of strings of users security role GUIDs:


god bless the boys from Power Objects

About these ads