1

I have two user column in SharePoint 2013 RequestedFor and CC. I want to display items only if the user in either column is equal current log in user.

So far I'm able to display items when Requested for is equal to log in user. I want to show items if the user is part of RequestedFor or CC field.

var userId = _spPageContextInfo.userId;function loadListItems(){var oDataUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('SupportList')/items?$select=ID,Created,Modified,Title,Status,RequestType,RequestedFor/Title,CC/Title&$expand=CC,AssignedTo/Title&$expand=RequestedFor,AssignedTo&$filter=RequestedFor eq " + userId;
console.log(_spPageContextInfo);
$.ajax(
{url: oDataUrl,
    type: "GET",
    dataType: "json",
    headers:
    {
        "accept": "application/json;odata=verbose"
    },
    success: successFunction,
    error: errorFunction
});}

1 Answer 1

0

Use your REST API endpoint similar to this:

"$select=Title,RequestedFor/ID,CC/ID&$expand=RequestedFor,CC&$filter=(RequestedFor/ID eq " + userId + " or CC/ID eq " + userId + ")";
1
  • 1
    Thank you this works!
    – Ace
    Commented Sep 2, 2020 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.