Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CRM Javascript Access Denied Error

Posted on 2010-08-18
2
Medium Priority
?
2,230 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

824 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