Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
632 views
in SharePoint Server by
closed by

I have the below script, its working fine with User/People , However, had change in the requirment to let items Filter by  AD groups . any thoughts to change.

$(".btn_Filter").on("click", e => {

        $(".btn_Filter").closest(".nav-item").removeClass("active");

        let filter_Type = $(e.target).data("filter");

        $(e.target).closest(".nav-item").addClass("active");

        $(".table-Header").text(filter_Type);

        if(filter_Type === "Assigned to Me") {
            
            let filtered_Arr = Observations_Arr.filter(item => {
                return item.AssignedToId !== null ? item.AssignedTo.Id === context.userId : "";
            });

            load_DataTable(filtered_Arr);

        } else if(filter_Type === "My Items"){
            
            let filtered_Arr = Observations_Arr.filter(item => {
                return item.Author.Id === context.userId;
            });

            load_DataTable(filtered_Arr);

        } else if(filter_Type === "My Staff Items") {

            

            sp.web.lists.getByTitle(Approvers_List).items.select("Title", "Person/Title").filter(`Person/Title eq '${context.userDisplayName}'`).expand("Person").get().then( items => {
                
                let group_shift = items.map(i => i.Title);
               
                let filtered_Arr = Observations_Arr.filter(item => group_shift.includes(item.Group_Shift.Title));
    
                load_DataTable(filtered_Arr);
            });

        } else if(filter_Type === "All Items"){
            sp.web.lists.getByTitle(Processing_Team).items.select("Title", "User/Title").filter(`User/Title eq '${context.userDisplayName}'`).expand("User").get().then( res => {
                
                console.log(res);

                let divisions = res.map(item => item.Title);
                
                let filtered_Arr = Observations_Arr.filter(item => divisions.includes(item.Division.Title));
    
                load_DataTable(filtered_Arr);
            });
        }
    });

your kind support is much appreicated.

closed with the note: Need more clarifications: Please add more details to can help you faster

If you don’t ask, the answer is always NO!
...