Upgrade Dynamics CRM 4 crmForm to Dynamics CRM 2011 Xrm.Page

1. Load external JavaScript files

If you load external JavaScript files by injecting a script element or use xmlhttprequest and you use relative path (include using a single forward slash /), you have to modify the relative path. Now the path has to be relative to

{CRM Server}/{Organization Name}/userdefined/edit.aspx page.

Or you can reference script web resources within that form

2. Hide field/control on the form

if you use

crmForm.all.fieldname_c.style.display = 'none'; crmForm.all.fieldname_d.style.display = 'none';

to hide a field, you can now use

Xrm.Page.getControl("fieldname").setVisible(false);

if you want to hide that field always without any condition, you can untick “Visible by default” checkbox when you customize that form

3.  Change form title

if you use

document.title = "title";

to change form title, you have to now use

window.parent.document.title = "title";

4. use xmlhttprequest or new ActiveXObject(“Msxml2.XMLHTTP”) to invoke external web service

if you use relative path before, Now the path has to be relative to

{CRM Server}/{Organization Name}/userdefined/edit.aspx

page.

5. Hide relationship entity grid toolbar buttons.

if you use unsupported JavaScript to work on DOM and hide these toolbar buttons, then you would better to use supported way to modify Ribbon xml to hide Ribbon button, as the toolbar is now replaced by Ribbon and there is no easy way to figure out when the Ribbon context tab will be available for the relationship iframe and grid.

6. use areas.aspx to display a list of related entity

you can insert a sub-grid in CRM 2011 or you can use the following script as well

// if interact with CRM 2011
 if (typeof window.top.opener.parent.Xrm != 'undefined') {
 /* when request page /cs/cases/areas.aspx in Microsoft Dynamics CRM 2011 (5.0.9688.1533)
 * Server will return 302 and redirect to /userdefined/area.aspx
 * This URL DOES NOT exist, only /userdefined/areas.aspx exist.
 */
 var redirectURL = 'http://' + serverName + '/' + orgName + '/userdefined/areas.aspx?oId=' + objectID + '&oType=' + objectTypeCode + '&security=' + securityCode + '&tabset=' + tabSet;
 window.location = redirectURL;
 }
 // if interact with CRM 4
 else {
 if (relationshipType == 'M') {
 var redirectURL = 'http://' + serverName + '/' + orgName + '/cs/cases/areas.aspx?oId=' + objectID + '&oType=' + objectTypeCode + '&security=' + securityCode + '&tabset=' + tabSet + '&roleOrd=' + roleOrd;
 window.location = redirectURL;
 }
 if (relationshipType == '1') {
 var redirectURL = 'http://' + serverName + '/' + orgName + '/userdefined/areas.aspx?oId=' + objectID + '&oType=' + objectTypeCode + '&security=' + securityCode + '&tabset=' + tabSet;
 window.location = redirectURL;
 }
 }

7. SetFieldRequiredOrRecommended

You can now use Xrm.Page.getAttribute(”).setRequiredLevel(‘none|required|recommended’)

or http://blog.arkesystems.com/post/2010/10/13/CRM-4-to-CRM-2011-SetFieldRequiredOrRecommended.aspx

CRM 4 CRM 2011
SetFieldRequiredOrRecommended(crmForm.all.new_notbillablereason_c, FORM_FIELD_TYPE_NORMAL, “”); SetFieldRequiredOrRecommended(crmForm.all.new_notbillablereason_c, FIELD_NOT_REQUIRED, “”);
SetFieldRequiredOrRecommended(crmForm.all.new_notbillablereason_c, FORM_FIELD_TYPE_RECOMMENDED, “”); SetFieldRequiredOrRecommended(crmForm.all.new_notbillablereason_c, FIELD_RECOMMENDED, “”);
SetFieldRequiredOrRecommended(crmForm.all.new_notbillablereason_c, FORM_FIELD_TYPE_REQUIRED, “”); SetFieldRequiredOrRecommended(crmForm.all.new_notbillablereason_c, FIELD_REQUIRED, “”);

ORG_UNIQUE_NAME –> Xrm.Page.context.getOrgUniqueName()
crmForm.ObjectId –> Xrm.Page.data.entity.getId()
crmForm.all.attributename.DataValue = result; –> Xrm.Page.getAttribute(“attributename”).setValue(result);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s