web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM REST builder code doesn't run in CRM. Error result not defined

(0) ShareShare
ReportReport
Posted on by

Hi,

I'm using CRM rest Builder to build my query and it works exactly as needed, but when I paste it into CRM I'm getting Success and result are not defined.  

function webapicode()
{
debugger;

Xrm.WebApi.online.retrieveRecord("contact", "9AD61380-F804-E711-8100-5065F38A5961", "?$select=_accountid_value,fullname,_parentcustomerid_value&$expand=parentcustomerid_account($select=telephone1)").then(
function success(result) {
var _accountid_value = result["_accountid_value"];
var _accountid_value_formatted = result["_accountid_value@OData.Community.Display.V1.FormattedValue"];
var _accountid_value_lookuplogicalname = result["_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
var fullname = result["fullname"];
var _parentcustomerid_value = result["_parentcustomerid_value"];
var _parentcustomerid_value_formatted = result["_parentcustomerid_value@OData.Community.Display.V1.FormattedValue"];
var _parentcustomerid_value_lookuplogicalname = result["_parentcustomerid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
if (result.hasOwnProperty("parentcustomerid_account")) {
var parentcustomerid_account_telephone1 = result["parentcustomerid_account"]["telephone1"];
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);

}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi,

    I just tried its working fine for me  . Try with different contact id and also debug your code .

    restapi.png

    Here is my code  -

    function GetRecord() {
        debugger;
    
        Xrm.WebApi.online.retrieveRecord("contact", "49A0E5B9-88DF-E311-B8E5-6C3BE5A8B200", "?$select=_accountid_value,fullname,_parentcustomerid_value&$expand=parentcustomerid_account($select=telephone1)").then(
            function success(result) {
                debugger;
                var _accountid_value = result["_accountid_value"];
                var _accountid_value_formatted = result["_accountid_value@OData.Community.Display.V1.FormattedValue"];
                var _accountid_value_lookuplogicalname = result["_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
                var fullname = result["fullname"];
                var _parentcustomerid_value = result["_parentcustomerid_value"];
                var _parentcustomerid_value_formatted = result["_parentcustomerid_value@OData.Community.Display.V1.FormattedValue"];
                var _parentcustomerid_value_lookuplogicalname = result["_parentcustomerid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
                if (result.hasOwnProperty("parentcustomerid_account")) {
                    var parentcustomerid_account_telephone1 = result["parentcustomerid_account"]["telephone1"];
                }
            },
            function (error) {
                Xrm.Utility.alertDialog(error.message);
            }
        );
    }
    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans