Solved

CRM Javascript Access Denied Error

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reference Error with plugin 1 31
validation, if text area is typed or pasted into 2 25
iPhone excel activation issues 11 70
Sorting a string 1 13
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

895 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

14 Experts available now in Live!

Get 1:1 Help Now