/script src="/..../jquery.min.js" type="text/javascript"/ script/script type="text/javascript"/
ExecuteOrDelayUntilScriptLoaded(checkUser, "sp.js");
//***************************************************************************************
// Function to check if user belongs to specific group or not and hide/unhide the control
//***************************************************************************************
var collection;
var user;
var group;
var userCollection;
var usercount=0;
function checkUser()
{
var ctx2 = new SP.ClientContext();
collection = ctx2.get_web().get_siteGroups();
group = collection.getById(5);
user = ctx2.get_web().get_currentUser();
userCollection = group.get_users();
ctx2.load(user);
ctx2.load(userCollection);//, 'Include(loginName)');
ctx2.executeQueryAsync(Function.createDelegate(this, this.onUserSuccess), Function.createDelegate(this, this.onUserFailed));
}
function onUserSuccess()
{
for(i=0;i{
if(user.get_loginName() == userCollection.itemAt(i).get_loginName())
{
usercount++;
}
}
if(usercount==0)
{
HideField("name of the column");
}
}
function onUserFailed()
{
}
function HideField(title){
var header_h3=document.getElementsByTagName("h3") ;
for(var i = 0; i{
var el = header_h3[i];
var foundField ;
if(el.className=="ms-standardheader")
{
for(var j=0; j{
if(el.childNodes[j].innerHTML == title
el.childNodes[j].nodeValue == title)
{
var elRow = el.parentNode.parentNode ;
elRow.style.display = "none"; //and hide the row
foundField = true ;
break;
}
}
}
if(foundField)
break ;
}
}/script/
ExecuteOrDelayUntilScriptLoaded(checkUser, "sp.js");
//***************************************************************************************
// Function to check if user belongs to specific group or not and hide/unhide the control
//***************************************************************************************
var collection;
var user;
var group;
var userCollection;
var usercount=0;
function checkUser()
{
var ctx2 = new SP.ClientContext();
collection = ctx2.get_web().get_siteGroups();
group = collection.getById(5);
user = ctx2.get_web().get_currentUser();
userCollection = group.get_users();
ctx2.load(user);
ctx2.load(userCollection);//, 'Include(loginName)');
ctx2.executeQueryAsync(Function.createDelegate(this, this.onUserSuccess), Function.createDelegate(this, this.onUserFailed));
}
function onUserSuccess()
{
for(i=0;i
if(user.get_loginName() == userCollection.itemAt(i).get_loginName())
{
usercount++;
}
}
if(usercount==0)
{
HideField("name of the column");
}
}
function onUserFailed()
{
}
function HideField(title){
var header_h3=document.getElementsByTagName("h3") ;
for(var i = 0; i
var el = header_h3[i];
var foundField ;
if(el.className=="ms-standardheader")
{
for(var j=0; j
if(el.childNodes[j].innerHTML == title
el.childNodes[j].nodeValue == title)
{
var elRow = el.parentNode.parentNode ;
elRow.style.display = "none"; //and hide the row
foundField = true ;
break;
}
}
}
if(foundField)
break ;
}
}/script/
No comments:
Post a Comment