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)

Filtering on SDK.REST.retrieveMultipleRecords problem

(0) ShareShare
ReportReport
Posted on by 120

Hi everyone!

I am trying to archieve the following using the SDK.REST.retrieveMultipleRecords and facing a problem concerning the ODATA filter.

I have a Entity 1 with a simple lookup field to Entity 2. Now I try to execute a retrieveMultipleRecords with the filter set to only list me instances of Entity 1 where the linked Entity 2 has a specific name.

I already tried to set the filter like this: "$select=*&$filter=<Name of the lookup field in Entity 1>/Name eq '" + <name parameter>+ "'";

and

"$select=*&$filter=<Name of the relationship between the two Entities>/Name eq '" + <name parameter>+ "'";

But in case 1 I get an error message: Error 400: Bad Request: Reference to property Name on complex type EntityReference is not supported.

In case 2 I get the error that there is no 'Name' property in the Type 'Microsoft.Xrm.Sdk.Entity' at position 45.

Can somebody maybe give me a hint on how to set the filter correctly so that i am able to filter records with the 'Name' Property of the inlining EntityReference as the base?

Thx in advance!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Somesh2207 Profile Picture
    1,563 on at

    I would suggest to use the new Web API in CRM. Filtering on link entity is possible and easy to do in Web API.

    BR

    Somesh Siripuram

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Seiffert,

    Try the following code for filtering. Here I am filtering the account records whose parent account (lookup) id is given.

    var entity2LookupId = Xrm.Page.data.entity.getId();
        if (entity2LookupId!= "") {
            var options = "/results$select=*&$filter=SchemaNameofLookUpIdInEntity1/Id eq guid'" + entity2LookupId+ "'";
            SDK.REST.retrieveMultipleRecords(
                        'Entity1SchemaName',
                        options,
                        function (results) {
                        },
                        function (error) {
                            alert(error.message);
                        },
                        function onComplete() {
                        }
                    );
        } 

    Hope it helps.

    Thanks

  • Community Member Profile Picture
    on at

    Based on my understanding, when you use odata to query with lookup field filter, you are query on the entityreference type record. The name is not unique ID for entityreference. You should use GUID instead of name.

    Below are example from MSDN:

    You can use the $filter query option to filter for the value of an EntityReference attribute. For example, if you have the Id value for a SystemUser record, you can retrieve a list of all the account records that a user is assigned by using the following filter:

    /AccountSet?$filter=OwnerId/Id eq (guid'" + SystemUserId + "')

  • Tin Profile Picture
    1,562 on at

    Have you got solution?

    I am getting same error,I need to filter lookup name basis not GUID.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans