Solved

CRM Javascript Access Denied Error

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i get 4 nd 5 ? 3 31
Saving excel document in lotus script 4 45
jQuery Dialog Autoresize Bug 2 25
on window close, not beforeunload 6 21
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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.
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

821 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