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)

Get record based on its guid through ODATA System query

(0) ShareShare
ReportReport
Posted on by

Hi guys,

how can I get a record based on its GUID via ODATA System Query ?

I have tried this, but no success:

https://server/org/XRMServices/2011/OrganizationData.svc/my_tableSet?$select=my_name&$filter=Id%20eq%20(Guid%2712930CE0-C842-E511-80C1-00155D017419%27)

Thanks.

*This post is locked for comments

I have the same question (0)
  • Abhishek Gupta Profile Picture
    2,003 on at

    Hi,

    There are multiple OData query tools which you can use to cross check your Query Url.

    One of them is CRMRestbuilder, follow below provided URL.

    crmrestbuilder.codeplex.com

    Please mark my answer as correct if you find so.

    Regards,

    Abhishek

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Donny, for fetching a single record with a known GUID via OData, the syntax is:

    <Organization Data Service URL>/<entityname>Set(guid'<yourGUIDHere>')

    • Note that your value for <entityname> is case sensitive.
      • Out-of-the-box entities typically start with capital letters (e.g. AccountSet), but custom entities typically are all lowercase (e.g. new_entitySet).
      • "Set" always uses a capital "S".
    • You can use either a single quote (') or %27 before and after the GUID.
  • Community Member Profile Picture
    on at

    Hi Kyle,

    I have expected that this is the only way to do this right ? So I cannot do it with filter ?

    Since my code is built that way, that I can only use the filter to achieve this..

    Thanks for your help

  • Community Member Profile Picture
    on at

    You can still do it with the $filter parameter, too; just make sure you're stating the id field correctly (remember, it's case sensitive!).  The example I gave is shorthand to accomplish the same thing, whenever you are retrieving a single record.  I only use the $filter parameter when I am querying by something other than the record id, which could return multiple records.

    The CRM SDK gives useful libraries for querying the REST endpoint, and lays out both a Retrieve and RetrieveMultiple method.  Also, checkout the XRMServiceToolkit libraries, which do the same, but also give the option of performing these queries synchronously OR asynchronously.

  • Community Member Profile Picture
    on at

    Hi Kyle,

    I meant, I want to get the record based on its GUID but via $filter and not with <Organization Data Service URL>/<entityname>Set(guid'<yourGUIDHere>')

    Is it possible ?

  • Community Member Profile Picture
    on at

    Yes you can do it using the $filter parameter.

    For example, these two queries return the same single record:

    <Organization Data Service URL>/AccountSet?$filter=AccountId eq (guid'1c2b8186-79c6-dd11-9e85-0014a4db888d')

    <Organization Data Service URL>/AccountSet(guid'1c2b8186-79c6-dd11-9e85-0014a4db888d')

    The second query just omits this string:

    "?$filter=AccountId eq"


    The difference is in the results...The top query returns an array of records, where your record is contained in the first and only <entry> node inside of a parent <feed> node.


    The second query returns the same data, but the single <entry> is NOT in a <feed> node.  The <entry> node is the top level node.

  • Community Member Profile Picture
    on at

    Hi Kyle,

    how can I find out what is the name of the id field ? I have a custom entity.

  • Verified answer
    Community Member Profile Picture
    on at

    It's usually just <custom entity name>Id.  For example new_MyEntityId.

    Since you're already working against that OData endpoint, you can use a more general query to get all of your entity's fields:

    <Organization Data Service URL>/<yourEntityName>Set?$top=1

    (Note: make sure that you're not using a "feed reader" view.  We want to see the raw XML, so disable that feed reader)

    Then, looking at the XML, do a control + F to find your id field and note it's exact capitalization.

  • Community Member Profile Picture
    on at

    Kyle,

    You are my Hero !!!

    Thanks a lot. It works !!

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