Live Webinar: Prompt Engineering: Skill Everyone Must Learn Today
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Script to hide SharePoint List Column for a particular SharePoint Group ID
WhatsApp
Krishna Murthy
Jul 15
2015
1.3
k
0
0
<script type=”text/javascript” src=”../_layouts/15/JS/jquery-1.11.2.min.js”></script>
<script type=”text/javascript”>
ExecuteOrDelayUntilScriptLoaded(getGroups, “sp.js”);
var
user;
var
visitorsGroup;
var
userCollection;
var
vGroupID = 6;
// Group ID for which the list column to be hidden
function
getGroups()
{
var
clientContext =
new
SP.ClientContext();
var
groupCollection = clientContext.get_site().get_rootWeb().get_siteGroups();
visitorsGroup = groupCollection.getById(vGroupID);
user = clientContext.get_web().get_currentUser();
userCollection = visitorsGroup.get_users();
clientContext.load(user);
clientContext.load(visitorsGroup);
clientContext.load(userCollection);
clientContext.executeQueryAsync(Function.createDelegate(
this
,
this
.onQuerySucceeded), Function.createDelegate(
this
,
this
.onQueryFailed));
}
function
onQuerySucceeded()
{
for
(
var
index = 0; index < userCollection.get_count(); index++) {
if
(userCollection.itemAt(index).get_loginName() === user.get_loginName())
{
//alert(“User present in this group”);
//if column name is title
$(‘nobr:contains(“Title”)’).closest(‘tr’).hide();
return
;
}
}
// alert(“User notpresent in this group”);
return
;
}
function
onQueryFailed(sender, args) {
//alert(“User notpresent in this group”);
return
;
}
</script>
Script
SharePoint
Up Next
Script to hide SharePoint List Column for a particular SharePoint Group ID