Monthly Archives: January 2013

Passing Calling User to an Aspx Page from Sitemap in CRM 2011

How to Pass the Calling User to an Aspx Page from Sitemap in CRM 2011

First, you need to create a simple HTML file and put the following codes in that page. Add the HTML file into the web resource. Call that file from your Sitemap. By the way, don’t forget to redirect to your aspx page in the HTML file. 🙂

<HTML><HEAD><TITLE></TITLE></HEAD>
<BODY onload=redirectAspxPage(); contentEditable=true>
<SCRIPT type=text/javascript src=”../ClientGlobalContext.js.aspx”></SCRIPT>

<SCRIPT type=text/javascript>
function redirectAspxPage() {

var userid = window.parent.Xrm.Page.context.getUserId();

window.location.href = “http://YOUR_URL/YOUR_PAGE.aspx?userid= ” + userid;
}
</SCRIPT>
</BODY></HTML>

Advertisements

2 Comments

Filed under Passing Calling User to an Aspx Page from Sitemap

Disable Form Fields in CRM 2011

How to Disable Form Fields in CRM 2011

This article is different from the previous one. This time, we are going to disable all the fields on a form in CRM 2011. The sample Java script is shown below.

function disableFormFields(onOff) {
Xrm.Page.ui.controls.forEach(function (control, index) {
if (doesControlHaveAttribute(control)) {
control.setDisabled(onOff);
}
});
}

function doesControlHaveAttribute(control) {
var controlType = control.getControlType();
return controlType != “iframe” && controlType != “webresource” && controlType != “subgrid”;
}

Leave a comment

Filed under Disable Form Fields, MS Dynamic CRM 2011

Readonly Entity Form in CRM 2011

How to Redirect to a Readonly Entity Form in CRM 2011

Sometimes, if you want to have a readonly form in CRM 2011, this article is what you want. We can call the following URL for readonly form in CRM 2011.

http://SERVER Name/ORG NAME/_forms/print/custformprint.aspx?

Query String Parameters

Parameter Value Comment
allsubgridspages Optional
true or false.
Default is false.
If CRM form has a Sub-Grid in it, this parameter decides whether to show Paging for the SubGrids. If set to true, it will show all the records of Sub-Grid, without any Pagination.
id Mandatory GUID. Guid of CRM entity record
formid GUID.
Optional
Form Id, if not given it and if there are multiple forms available for given entity it will follow CRM’s way of showing appropriate form.
objectType Mandatory Number. Object Type Code for Entity

Here is the sample Java script for that.

changeToReadOnlyPage = function()Here is the sample JavaScript function.

{
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_READONLY = 3;

if( Xrm.Page.ui.getFormType()== CRM_FORM_TYPE_CREATE)
window.location =Xrm.Page.context.getServerUrl() + “/” + Xrm.Page.context.getOrgUniqueName() +
“/_forms/print/custformprint.aspx?objectType=” + Xrm.Page.context.getQueryStringParameters().etc;
else if( Xrm.Page.ui.getFormType() != CRM_FORM_TYPE_READONLY)
window.location = Xrm.Page.context.getServerUrl() + “/” + Xrm.Page.context.getOrgUniqueName() +
“/_forms/print/custformprint.aspx?id=” + Xrm.Page.data.entity.getId()+ “&objectType=” + Xrm.Page.context.getQueryStringParameters
().etc;
}

Leave a comment

Filed under MS Dynamic CRM 2011, Readonly Entity Form