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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

WebApi cannot retrieve lookuplogicalname

(0) ShareShare
ReportReport
Posted on by 155

I'm trying to access logical name of the entity referenced by the lookup but for some reason the response doesn't contain Microsoft.Dynamics.CRM.lookuplogicalname property. 

sts_origmeeting is a lookup to appointment entity. As appointment can be created from contact/account. i'm trying to access the lookuplogicalname but i don't see this in the response. Please suggest me a solution to access lookuplogicalname.

function TestApp()
{
	var serverURL = Xrm.Page.context.getClientUrl();
	var origmeetingvalue = window.parent.Xrm.Page.getAttribute("sts_origmeeting").getValue();
	var appid = origmeetingvalue[0].id.toString();
	appid = appid.replace('{', '');
	appid = appid.replace('}', '');
	var req = new XMLHttpRequest();
	req.open("GET",
	Xrm.Page.context.getClientUrl() +
		"/api/data/v8.1/appointments(" + appid + ")?$select=_regardingobjectid_value",
	false);
	req.setRequestHeader("OData-MaxVersion", "4.0");
	req.setRequestHeader("OData-Version", "4.0");
	req.setRequestHeader("Accept", "application/json");
	req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
	req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
	req.setRequestHeader("Prefer", "odata.maxpagesize=10");
	req.onreadystatechange = function ()
	{
		if (this.readyState == 4 /* complete */ )
		{
			req.onreadystatechange = null;
			if (this.status == 200)
			{
				var data = JSON.parse(this.response);
                alert(data.value[0]["_regardingobjectid_value@Microsoft.Dynamics.CRM.lookuplogicalname"]);
			}
			else
			{
				var error = JSON.parse(this.response).error;
				alert(error.message);
			}
		}
	};
	req.send();
}


*This post is locked for comments

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

    Why don't you generate your code using CRMRestBuilder. You will get auto generate code.

    www.youtube.com/watch

    You can also check here for sample code-

    community.dynamics.com/.../900404

    community.dynamics.com/.../899799

  • Itz_Me_Ram Profile Picture
    155 on at

    I tried using Rest builder.I can see _regardingobjectid_value in the response.But data[_regardingobjectid_value@Microsoft.Dynamics.CRM.lookuplogicalname] is undefined.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Try to do like below , its should work ,

    2019_2D00_02_2D00_23_5F00_11_2D00_21_2D00_38.png

    2019_2D00_02_2D00_23_5F00_11_2D00_21_2D00_38.png

    2019_2D00_02_2D00_23_5F00_11_2D00_22_2D00_13.png

                function TestApp()
                {
                    var serverURL = Xrm.Page.context.getClientUrl();
                    var origmeetingvalue = window.parent.Xrm.Page.getAttribute("sts_origmeeting").getValue();
                    var appid = origmeetingvalue[0].id.toString();
                    appid = appid.replace('{', '');
                    appid = appid.replace('}', '');
    
                    var req = new XMLHttpRequest();
                    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/appointments?$select=activityid,actualend,actualstart,_regardingobjectid_value&$filter=activityid eq "+appid+"", true);
                    req.setRequestHeader("OData-MaxVersion", "4.0");
                    req.setRequestHeader("OData-Version", "4.0");
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
                    req.onreadystatechange = function() {
                        if (this.readyState === 4) {
                            req.onreadystatechange = null;
                            if (this.status === 200) {
                                var results = JSON.parse(this.response);
                                for (var i = 0; i < results.value.length; i++) {
                                    var activityid = results.value[i]["activityid"];
                                    var actualend = results.value[i]["actualend"];
                                    var actualstart = results.value[i]["actualstart"];
                                    var _regardingobjectid_value = results.value[i]["_regardingobjectid_value"];
                                    var _regardingobjectid_value_formatted = results.value[i]["_regardingobjectid_value@OData.Community.Display.V1.FormattedValue"];
                                    var _regardingobjectid_value_lookuplogicalname = results.value[i]["_regardingobjectid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
                                    alert(_regardingobjectid_value_lookuplogicalname);
                                }
                            } else {
                                Xrm.Utility.alertDialog(this.statusText);
                            }
                        }
                    };
                    req.send();
                }


  • gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Did you tried with this which I shared above ?

  • Suggested answer
    Itz_Me_Ram Profile Picture
    155 on at

    Yes i tried..it is an environment issue. Thank you!!

  • Aarti Parpiyani Profile Picture
    20 on at

    @Itz_Me_Ram   Is it because of the latest update?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
NeerajPawar Profile Picture

NeerajPawar 2

#2
jlattimer Profile Picture

jlattimer 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans