0

I am looking for a way how to export sharepoint groups via javascript of specific user(filled via input box). Can someone advise please? I managed to export all groups on sharepoint as well as currently logged in but not specific one. I also found the basics on microsoft web but there is nothing about specific user.

Is it somehow possible via REST?

Thank you

Rudolf
  • 48
  • 1
  • 1
  • 7

1 Answers1

0

So I managed to do it with this functions if anyone is interested.

function GetMembersOfGroup(grpName){
  $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups/getByName('"+ grpName +"')/users",
    type: "GET",
    headers: {"accept": "application/json;odata=verbose"},
    success: function (data){
      if (data.d.results)
      {
        for (var i = 0; i < data.d.results.length; i++) {
      //Loop through all users and binding in dropdown
          if (data.d.results[i] != null && data.d.results[i] != undefined) {
            if (data.d.results[i].LoginName == "i:0#.w|ad\\" + document.getElementById("userCkToRemove").value.toLowerCase()) {
              if ($("#groupNameToRemove option[value='" + data.d.results[i] + "‘]").length == 0) {
                $('#groupNameToRemove').append($("<option/>", {
                value: data.d.results[i].Email,
                text: grpName
                }));
              }
            }
          }
        }
       }
     },
     error: function (error) {
     alert(JSON.stringify(error));
     }
   });
 }

This functions exports all members and checks whether the login name of export "file" equals the login name that we want to search (coming from input box in html). If yes then we add the name of the group in the drop-down tag based on id #groupNameToRemove which is select tag and I create and option tag within it per each group that the user is member

Rudolf
  • 48
  • 1
  • 1
  • 7