Skip to main content
Dynamics 365 general forum
Suggested answer

Odata ?$select=""&$filter - How to work with or operator?

editSubscribe (0) ShareShare
ReportReport
Posted on by 10

Hello all & Happy Friday,

I'm trying to append an OR operator to this working JS and cannot find many examples in D365 online.

Following: https://community.dynamics.com/365/b/goutamdas/posts/how-to-pass-multiple-guid-in-xrm-webapi-retrievemultiplerecords

and using error checking from Visual studio code I've gone from:

Working: 

Xrm.WebApi.retrieveMultipleRecords("red_subjectivity""?$select=red_name&$filter=_red_binder_value eq " + recordId).then(

TO

Not Working: 
Xrm.WebApi.retrieveMultipleRecords("red_subjectivity""?$select=red_name&$filter=_red_binder_value eq " + recordId + or ('red_status eq') ("283390001")).then(


Objective: To add an OR statement for the record status eq to "283390001"

Thanks for all your help and guidance on the matter. :)
Attachments
  • Ky0l Profile Picture
    Ky0l 10 on at
    RE: Odata ?$select=""&$filter - How to work with or operator?

       Xrm.WebApi.retrieveMultipleRecords("red_subjectivity", "?$select=red_name,red_status&$filter=_red_binder_value eq " + recordId).then(

           function success(result) {

               var subgridLength = result.entities.length;

               if (subgridLength == 0) {

                   if (formContext.getControl('red_status') != null)

                   formContext.getControl('red_status').removeOption(283390002); //Hide "Approved with Subjectivities" value

               }

               else if (subgridLength > 0) {

                   for (var i = 0; i < subgridLength; i++) {

                       if (result.entities[i]["red_status"] != 283390001 && formContext.getControl('red_status') != null) {

                           formContext.getControl('red_status').removeOption(283390003); //Hide "Approved" value

                       }

                   }

               }

           },

           function (error) {

               alert("Failure");

               console.log(error.message);

           }

       );

    }

  • Ky0l Profile Picture
    Ky0l 10 on at
    RE: Odata ?$select=""&$filter - How to work with or operator?

    Didn't quite work, however a consultant is looking at it tomorrow and will post the results. :)

  • Suggested answer
    PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: Odata ?$select=""&$filter - How to work with or operator?

    hi,

    try like this

    "?$select=red_name&$filter=(_red_binder_value eq "   recordId  " or red_status eq 283390001)"

    if red_status is a string value then surround '283390001' if it's a number value then let it as example above.

  • Suggested answer
    RE: Odata ?$select=""&$filter - How to work with or operator?

    Hello KyOl, 

    I hope you are doing well. 

    I believe that this 3rd party tool named FetchXml Builder can help to to perform it https://fetchxmlbuilder.com/features/ into XRMToolBox that you can see more details here https://www.xrmtoolbox.com/ 

    Also you can work with CRM Rest Builder solution https://github.com/jlattimer/CRMRESTBuilder 

    Kind Regards, 

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,126 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,646 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans