RemoveUserFromGroup method not working

Sep 2, 2014 at 2:54 PM
Edited Sep 2, 2014 at 2:55 PM
This RemoveUserFromGroup method is not doing anything when i execute this piece of code.

I use the same groupname for "GetUserCollectionFromGroup" method where it pulls out all user information. for removal part also i am using the same group name & login name which has been populated by GetUserCollectionFromGroup. but no operation is getting performed

can anyone please help, how to make it work / get ResponseText from Data object ?

Below the Code Snippet

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js"></script>

function LoadTable()
{
$().SPServices({
    operation: 'GetUserCollectionFromGroup', 
    async: false, 
    cache: false, 
    groupName: 'TestGroup',
    completefunc: function (data) 
    {
        //alert(data.responseText);
        $(data.responseXML).find("User").each(
        function () 
        {
            var UserLoginName=encodeURI($(this).attr('LoginName'));
            //alert(UserLoginName);
            $("#DeletionTable").append("<tr><td width='60%'>"+$(this).attr('Name')+"</td><td width='30%'>"+$(this).attr('LoginName')+"</td><td width='10%'><input type='button' onClick=DeleteClick('"+UserLoginName+"') value='Delete'></td></tr>");
        });
    }
});
  $('#DeletionTable').dataTable();
}
function DeleteClick(LoginName)
{
LoginName=decodeURI(LoginName);
if (confirm("Are you sure to Delete User From Group?"))
{
    DeleteUserFromGroup('TestGroup',LoginName);
    location.reload();
}
return false;

}

function DeleteUserFromGroup(GroupName,LoginName)
{
    alert(GroupName +"   ,  " +LoginName);
    $().SPServices(
        {
            operation: "RemoveUserFromGroup",
                        groupName: GroupName,
                        userLoginName: LoginName
        }
    );
}
Coordinator
Sep 2, 2014 at 3:06 PM
Have you looked at the Net traffic to see if you are getting any errors? Have you tried to hard-wire one delete to ensure your code is right?

M.
Sep 2, 2014 at 5:36 PM
Thanks for your clue, actually the next line of the code location.reload was cause for this problem since i called this method with async mode. so location.reload was fired before delete method.. now after setting async =false. it works fine.