Notifications
Announcements
No record found.
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
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
Hi Donny, for fetching a single record with a known GUID via OData, the syntax is:
<Organization Data Service URL>/<entityname>Set(guid'<yourGUIDHere>')
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
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.
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 ?
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.
how can I find out what is the name of the id field ? I have a custom entity.
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.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2