Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Answered

How to remove the current case from the results retrieved by Web API

(0) ShareShare
ReportReport
Posted on by 77

Hi, 

I am working on showing sibling cases whose parent is same by retrieving the child cases based on parent case using WebAPI retrieve where I would like to remove the current case from the list of results returned.

For example: Lets say...I have

Parent Case ABC got three child cases Test1, Test2 and Test 3.

If I am on Test 2 case, I would like to see...Test1 and Test3 cases as sibling cases but not all three of them. At present, I am retrieving all the three cases based on parent case but I would like to remove the current case from the list returned. Could someone please suggest me is there any way to achieve this. Thanks

  • D365Admin Profile Picture
    D365Admin 77 on at
    RE: How to remove the current case from the results retrieved by Web API

    It worked. Thank you.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to remove the current case from the results retrieved by Web API

    Hi D365Admin,

    As Andrew Butenko said, the request url should be like this: var url = [organization URI] + "/api/data/v9.2/incidents?$select=title&$filter=parentcaseid/incidentid eq " + parentCaseID + " and incidentid ne " + caseID;

    Here is my ajax request sample :

    function openUrl(executionContext) {
    var parentCaseID = "xxx";
    var caseID = "xxx";
    var url = "[organization URI]" + "/api/data/v9.2/incidents?$select=title&$filter=parentcaseid/incidentid eq " + parentCaseID + " and incidentid ne " + caseID;
    var request = new XMLHttpRequest();
    request.open("get", url , true);
    request.setRequestHeader("OData-MaxVersion", "4.0");
    request.setRequestHeader("OData-Version", "4.0");
    request.setRequestHeader("Accept", "application/json");
    request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    request.onreadystatechange = function () {
    if (request.readyState === 4) {
    console.log(JSON.parse(request.responseText));
    }
    }
    request.send();
    }

  • Verified answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: How to remove the current case from the results retrieved by Web API

    Hello,

    I believe you have the id of the current incident and id of the parent case so the query should look like "Select cases where parent case id equals PARENTCASEID and case id is not equal Test2. Should be simple enough.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans