Tag Archives: Java Script

Getting View Details from CRM Grid (CRM 4.0 vs. CRM 2011)

We had custom application which uses were passing selected view id to our custom web page in CRM 4.0, following code we put in JavaScript button click event to retrieve this details.


if (top.stage.crmGrid != null)
{
var sViewId = top.stage.crmGrid.GetParameter('viewid');
var sViewType = top.stage.crmGrid.GetParameter('viewtype');
var sOtc = top.stage.crmGrid.GetParameter('otc');
}

Above code does not work in CRM 2011 and by doing really simple change as mentioned below, so following code works fine for CRM 2011..


if (document.getElementById('crmGrid') != null) {
var sViewId = document.getElementById('crmGrid').GetParameter('viewid');
var sViewType = document.getElementById('crmGrid').GetParameter('viewtype');
var sOtc = document.getElementById('crmGrid').GetParameter('otc');
}

Hope this helps..

Note: This is unsupported customization, Please unit test this module on your development/test environment before applying it to Live Environment.

Cheers,
Mayank:)

CRM 4.0 Printing Error – This form has been changed and must be saved before printing.

One of user posted this error in this CRM thread, we had similar issue some time back and one of my colleagues had resolved this issue.

Problem
This error comes if you got java script code which is constantly updating some variables in the back ground. This makes CRM Form engine believes that form has been changed so CRM print function will not allow you print CRM form.

Solution
The solution for this is that we over ride existing CRM print on click event and write function to run this print job manually.
Following is example script for Phone call entity. This script needs to put in to the Form On Load Event.

Following text version of above code, change the object type code as per your requirement.

if (document.getElementById('_MBcrmFormPrint') != null)
{
document.getElementById('_MBcrmFormPrint').action = ' openStdWin(prependOrgName("/_forms/print/print.aspx?objectType=4210&id=" + crmForm.ObjectId + "&title=" + CrmEncodeDecode.CrmUrlEncode(parent.document.title))); ';
}

Hope this helps!!

Note: – This is unsupported change so please make sure you take necessary back up before doing this change.

Cheers,
MayankP 🙂

CRM 4.0 Java Script “Error: Access is denied”

If you have written Fetch Xml code using Java script then there would be case when specific user will get the following error

“This page is accessing information that is not under its control. Thos poses a security risk. Do you want to continue?

Case Page

And then if user continues it gets following error

Case Page

Potential Solution:
 Click on Tools in the Internet Explorer tool bar menu and
 Then select Internet Options from the drop down.
 Now click the Security tab and then click the “Custom Level” button.
 Once this is open scroll down until you see the “Access data sources across domains” setting and set the radial button to enable.
 Click the OK button followed by the Apply button to save the settings

Hope this helps