Skip to main content

Notifications

Announcements

No record found.

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

  • Aarti Parpiyani Profile Picture
    20 on at
    RE: WebApi cannot retrieve lookuplogicalname

    @Itz_Me_Ram   Is it because of the latest update?

  • Suggested answer
    Itz_Me_Ram Profile Picture
    155 on at
    RE: WebApi cannot retrieve lookuplogicalname

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

  • gdas Profile Picture
    50,089 Moderator on at
    RE: WebApi cannot retrieve lookuplogicalname

    Hi ,

    Did you tried with this which I shared above ?

  • Verified answer
    gdas Profile Picture
    50,089 Moderator on at
    RE: WebApi cannot retrieve lookuplogicalname

    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();
                }


  • Itz_Me_Ram Profile Picture
    155 on at
    RE: WebApi cannot retrieve lookuplogicalname

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

  • Suggested answer
    gdas Profile Picture
    50,089 Moderator on at
    RE: WebApi cannot retrieve lookuplogicalname

    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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,280 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,038 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans