Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Weird issue in Web-API while retrieving data from CRM

Posted on by Microsoft Employee

Hi All,

We have a CRM Application for which we had a library to make CRUD operations using REST and SOAP, since CRM will soon stop supporting that so we are moving all the JavaScript to WEBAPI calls. 

Initially we had a fetchxml which executes and give responses which we then parse.

But now the same fetchxml response is a bit wired.

1) If the attribute is of Lookup(EntityReference) then in WEBAPI i'm getting only guid but not the entityname and name of the lookup record. This attribute name is also a bit different for eg if the attribute name is "sw_product" then in response the attribute name would be "_sw_product_value".

2) Since I am not getting the name of a lookup record so thought of using linked-entity and tried to add the name field of lookup record, I am getting the response but again the schema name gets appends to some characters eg - productlink_x002e_name. (productlink - is the alias name).

Any Suggestions on how to do this?

Thanks,

Vijay

*This post is locked for comments

  • Verified answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Weird issue in Web-API while retrieving data from CRM

    HI

    You have to include in the web API header below

    retrieveReq.setRequestHeader("prefer", "odata.include-annotations="*");

  • Kristian Cole Profile Picture
    Kristian Cole 290 on at
    RE: Weird issue in Web-API while retrieving data from CRM

    try:

    var guid = yourlookupfield[0].id;

    var name = yourlookupfield[0].name;

    var entitytype = yourlookupfield[0].entityType;

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans