Link to home
Start Free TrialLog in
Avatar of BigBlueMan
BigBlueManFlag for United Kingdom of Great Britain and Northern Ireland

asked on

CRM Javascript Access Denied Error

Hello

I've seen this issue a few times on various blogs and wondering if the experts can help... I have the following piece of JS below.

What its essentially doing is obtaining the parent objectid of one of our customized entities, application form. The parent form is the Contact form.
With the object id it then runs a little function which send fetchXML query to retrieve a piece of data from a relating form (lead) and bring it back.

This piece of code works find thru the CRM Web Client. However it fails when CRM is used thru Outlook, with a 'Access is Denied' error message.

However, it works for me thru Outlook as I am Domain admin user but fail for a general user..
Some users are also running Windows 7 in case that is related..


thanks

if (crmForm.all.new_fundercasenumber.DataValue == null) {
    if ( window.opener) //checks if current window has a parent window
    {
        var oParentForm = window.opener.parent.document.getElementById('crmForm');
        if ( oParentForm == null) {
            oParentForm = window.opener.parent.document.crmForm;
        }
        if ( oParentForm) //This confirms if the parent window is a CRM form
        {
            // Now try to access a field in the parent form.
            if ( oParentForm.ObjectId) //This ensures you have reached the form you're looking for
            {
                var fundingNumber = getEnquiryFundCaseNumber(oParentForm.ObjectId);
                if ( fundingNumber != null) {
                    crmForm.all.new_fundercasenumber.DataValue = fundingNumber;
                }

            }
        }
    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GoJoeIsBlue
GoJoeIsBlue

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BigBlueMan

ASKER

You are correct ..don't know why I did not think of doing it that way... Placed a lookup to parent A on form B and changed my code to below... Works fine.

// bring in funding case number from enquiry, if its not given.
if (crmForm.all.new_fundercasenumber.DataValue == null) {
    var contactLookup = crmForm.all.new_applicantid.DataValue;
    if ( contactLookup != null) {  //This confirms if the parent window is a CRM form
        var fundingNumber = getEnquiryFundCaseNumber( contactLookup[0].id);
        if (fundingNumber != null) {
            crmForm.all.new_fundercasenumber.DataValue = fundingNumber;
        }
    }
}