Fetching Login User Group Using Ecma Script
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', CheckCurrentUserGroup);
function CheckCurrentUserGroup() {
var clientContext = new SP.ClientContext.get_current();
currentUser = clientContext.get_web().get_currentUser();
clientContext.load(currentUser);
userGroups = currentUser.get_groups();
clientContext.load(userGroups);
clientContext.executeQueryAsync(OnQuerySucceededUserGroup,OnQueryFailedUserGroup);
}
function OnQuerySucceededUserGroup() {
var isMember = false;
var groupsEnumerator = userGroups.getEnumerator();
var currUser=currentUser.get_title();
while (groupsEnumerator.moveNext()) {
var group= groupsEnumerator.get_current();
if(group.get_title() == "XXX") {
/* Logic */
}
}
}
function OnQueryFailedUserGroup() {
}
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', CheckCurrentUserGroup);
function CheckCurrentUserGroup() {
var clientContext = new SP.ClientContext.get_current();
currentUser = clientContext.get_web().get_currentUser();
clientContext.load(currentUser);
userGroups = currentUser.get_groups();
clientContext.load(userGroups);
clientContext.executeQueryAsync(OnQuerySucceededUserGroup,OnQueryFailedUserGroup);
}
function OnQuerySucceededUserGroup() {
var isMember = false;
var groupsEnumerator = userGroups.getEnumerator();
var currUser=currentUser.get_title();
while (groupsEnumerator.moveNext()) {
var group= groupsEnumerator.get_current();
if(group.get_title() == "XXX") {
/* Logic */
}
}
}
function OnQueryFailedUserGroup() {
}
No comments:
Post a Comment