Solved

CRM Javascript Access Denied Error

Posted on 2010-08-18
2
2,173 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:BigBlueMan
2 Comments
 
LVL 3

Accepted Solution

by:
GoJoeIsBlue earned 500 total points
ID: 33468648
Well as I read your post this occurs when you open an "Entity B" record from an open "Entity A" record, correct?
And the script is running on "Entity B", still correct?

If you answered "Yes" to both questions read on, otherwise jump to "FINALLY".

If "Entity B" is in a Many-To-One relation with "Entity A" you should have a lookup on "Entity B" refering to the parent "Entity A" record. Thus, instead of going through window.open just grab the ID from the lookup.

If on the other hand "Entity B" is in a One-To-Many relation the lookup will be on "Entity A", in this case place a little javascript on "Entity A" which alters the link which opens "Entity B" by adding the ObjectId of "Entity A".



FINALLY:
And finally you should check that general user can execute the query you have in getEnquiryFundCaseNumber, you could do this by adding an ISV-button to "Entity A".
0
 

Author Closing Comment

by:BigBlueMan
ID: 33473113
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;
        }
    }
}
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question