as per my requirements

  • Check current user is present in manager group
  • If not present Check status columns
  • If status column consist value other than Requested then stop user to Save item

so for that I have used PreSaveAction() function. I have achieved my requirement here but not It stop save item in list even if Member is available in manager group

Here is screen shot of List Item enter image description here

Here is my code

 var j = jQuery.noConflict(); 
 function PreSaveAction() {

    var context = new SP.ClientContext.get_current();
    var currentWeb = context.get_web();

    var currentUser = context.get_web().get_currentUser();

    var allGroups = currentWeb.get_siteGroups();

    var group = allGroups.getByName('Marketing');

    var groupUsers = group.get_users();

            function(sender, args) {
               var userInGroup = IsUserInGroup(currentUser,group);   

                alert('avaliable in group');
                return true; 

                var txtTitle = j(":input[title='Status']").val(); 

                if(txtTitle != 'Requested')
                  alert("Please Select other status ");
                  return false; 
                 return true; 


               alert('Not avaliable in group');


            function OnFailure(sender, args) {
               alert('Not Avaliable');
                var userInGroup = IsUserInGroup(currentUser,group);   

    function IsUserInGroup(user,group)
        var groupUsers = group.get_users();
        var userInGroup = false;
        var groupUserEnumerator = groupUsers.getEnumerator();
        while (groupUserEnumerator.moveNext()) {
            var groupUser = groupUserEnumerator.get_current();
            if (groupUser.get_id() == user.get_id()) {
                userInGroup = true;


        return userInGroup;

1 Answer 1


Its because you are doing it async, instead of returning return true, send in the form using SPClientForms.ClientFormManager.SubmitClientForm

Its already available on the form variable created by SP:


If you are using PreSaveAction, you'll need to return false on the initial save to avoid multiple "saves":


window.PreSaveAction = function() { 
    SP.SOD.executeFunc("sp.js", "SP.ClientContext", function() { 

        var context = SP.ClientContext.get_current();
        context.load(context.get_web(), "Title");
        context.executeQueryAsync(function() { 

        }, function(s,args) { console.log(args.get_message()) })


    return false; 
  • Anders Aune Your solution works for me.. But it save item 2 times.. don't know but I will Figure it out. Commented Aug 8, 2016 at 13:14
  • Same issue for me item save 2 times how can you avoid ?
    – Admin
    Commented Dec 26, 2016 at 10:28
  • @Admin updated my answer Commented Dec 28, 2016 at 11:07

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.