Skip to content

Instantly share code, notes, and snippets.

@hemache
Created April 22, 2016 13:07
Show Gist options
  • Save hemache/ca1cb13a180cb852a86567b2656dc998 to your computer and use it in GitHub Desktop.
Save hemache/ca1cb13a180cb852a86567b2656dc998 to your computer and use it in GitHub Desktop.
SharePoint people picker prevent select everyone group
function PreSaveAction() {
try {
var selectedValues = JSON.parse($('[id*="$ClientPeoplePicker_HiddenInput"]').val()),
returnValue = true;
for(i=0; i < selectedValues.length; i++){
var selectedValue = selectedValues[i];
if(selectedValue.IsResolved && (selectedValue.ProviderName == "AllUsers" || selectedValue.Key == "c:0(.s|true")){
returnValue = false;
}
if(!selectedValue.IsResolved && (selectedValue.Key.toLowerCase() == "tout le monde" || selectedValue.Key == "الجميع")){
returnValue = false;
}
}
} catch(e){
}
return returnValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment