Access Denied on CRM form

Jul 3, 2013 at 3:36 PM
Hi there!

I'm doing a Xrm.ServiceToolkit.Rest.Retrieve to pull some data from a parent record (through parentcustomerid) but getting an Access is Denied. I've pretty much used the function from the documentation section. Am I missing something?

Pete :)
Coordinator
Jul 3, 2013 at 3:52 PM
Hi There.

If you can provide a bit more details about where the code is called, that would be helpful.

Access is denied normally happens when you try to use JavaScript cross domain.

Jaimie
Jul 3, 2013 at 4:24 PM
Edited Jul 3, 2013 at 4:26 PM
Apologies, code is below :)
I'm basically just calling the below in a function when you update the parentcustomerid field on a Contact form. This is all there is it to it so far.
var accountObject = Xrm.Page.getAttribute("parentcustomerid");

if (accountObject != null)
{
    var accountValue = accountObject.getValue();
    {
        var accountId = accountValue[0].id;
        
        XrmServiceToolkit.Rest.Retrieve(
            accountId,
            "AccountSet",
            null, null,
            function (result)
            {
                alert(result.AccountId);
            },
            function(error)
            {
            },
            false
        );
    }
}
Thanks,

Pete
Jul 4, 2013 at 10:29 AM
I've just realised that the CRM deployment is on RU6, which I'm sure isn't going to be helping. Rolling that up now so will let you know if this cures it :)

Pete
Jul 4, 2013 at 1:19 PM
Hello again!

Numpty alert - It was indeed because it was cross server, and I hadn't set up a mapping against a host name...

Pete