Solved

CRM Javascript Access Denied Error

Posted on 2010-08-18
2
2,163 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now