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)

Problem with the filter option of SDK.REST.retrieveMultipleRecords

(0) ShareShare
ReportReport
Posted on by 37

Hi!

First post ever, hope you guys can give me some valuable help for my problem!

So I am writing a JS script in order to retrive some PhoneCalls which RegardingObjectId is the same of my current incident. To do that, I am using the function SDK.REST.retrieveMultipleRecords.

I have a problem setting the option of my query. I try to set the filter as below:

var optionString = "/PhoneCall?$filter=RegardingObjectId/Id eq (guid'" + editedFormGuid + "')"

but I have the feeling the filter is ignored and what is return by the function is ALL the PhoneCall records, instead of the ones that interest me.

This is how I call the function :

SDK.REST.retrieveMultipleRecords(
            "PhoneCall",
            optionString,
            successCallbackPhoneCall,
            function (error) { alert("errorCallBack message \n" + error.message); },
            function () {Xrm.Utility.alertDialog("retrieve completed");}
            );


Thanks,

Anthony

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to replace line

    var optionString = "/PhoneCall?$filter=RegardingObjectId/Id eq (guid'" + editedFormGuid + "')";

    with line

    var optionString = "$filter=RegardingObjectId/Id eq (guid'" + editedFormGuid + "')";


  • cchanthony Profile Picture
    37 on at

    Hi Andrii,

    Thanks for your reply.

    I've try that already, but the result is the same.

    Actually I cheated a bit on the Guid of my incident.

    At the begining, I get the incident Id with :

                

    var idForm = Xrm.Page.data.entity.getId();


    then I notice that the string that I've got is like

    "{825CB223-A651-DF11-AA8B-00155DBA3804}"

    and when i check the RegardingObjecctId, once I retrieve the data, I have the same string BUT without those characters " and {, also in lowercase        

    825cb223-a651-df11-aa8b-00155dba3804

    So the <editedFormGuid>, that I used in the function is the GUID in lowercase exactly as above.

    thanks,

    Anthony

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Then the only way to discover why you code doesn't work properly is to troubleshoot it using Developer Tools. I use Chrome.

  • Verified answer
    cchanthony Profile Picture
    37 on at

    Thank you for your help Andrii.

    I found out what was wrong with my script.

    Previously the option was set as below :

    var idForm = Xrm.Page.data.entity.getId();
    var optionString = "/PhoneCall?$filter=RegardingObjectId/Id eq (guid'" + idForm+ "')"

    The to get this filter works is :

    var idForm = Xrm.Page.data.entity.getId();
    optionString: "$select=*&$filter=RegardingObjectId/Id eq (guid'" + idForm + "')"

    Now I only retrieve records which RegardingObjectId is equal to the ID of my incident


    Anthony

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