1

How do you go about filtering the list using items from multi value field? For example: If current user is the timekeeper for UnitA and UnitB, I want to filter another list to display only items from UnitA and UnitB.

Choice field name: UnitNames

I currently have the following to get the UnitNames:

var requestUri = webAbsUrl + "/_api/web/Lists/getByTitle('Directory')/Items?$\
    filter=Title eq '" + currentUserEmail + "'&$\
    select=Id, UnitNames";

var ajax = $.ajax({
    url: requestUri,
    async: false,  
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
        var countAjaxOrg = data.d.results.length;
            if(countAjaxOrg > 0) {
                var myUnitGroup = data.d.results[0].UnitNames;
        }
    },
    error: function (data) { alert("Failed to load data."); }
});

I tried a simple alert alert(myUnitGroup); and it returns [object Object]. I need to filter another list with whatever values are returned from above but I cant figure out how to retrieve values from choice field.

2

I believe you have to add ".results" to the end of your call if you're using SP2013 or above:

var myUnitGroup = data.d.results[0].UnitNames.results;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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