I am fairly new to SharePoint Online... What I am trying to accomplish is hiding a certain field in the View and Edit view mode on a Custom List. I have found articles on it but can't seem to figure what I am doing wrong because nothing I do works. I am entering the following code as SEWP in both the View and Edit view modes.
The goal I am trying to achieve: Hide the "Feedback" column if the user IS NOT part of the "Template Test Members" permission group.
<script type="text/javascript>
function checkUser() {
IsCurrentUserMemberOfGroup("Template Test Members", function(isCurrentUserInGroup) {
if (isCurrentUserInGroup) {
} else {
document.getElementById("Feedback").style.display = "none";
}
});
}
function IsCurrentUserMemberOfGroup(groupName, OnComplete) {
var currentContext = new SP.ClientContext.get_current();
var currentWeb = currentContext.get_web();
var currentUser = currentContext.get_web().get_currentUser();
currentContext.load(currentUser);
var allGroups = currentWeb.get_siteGroups();
currentContext.load(allGroups);
var group = allGroups.getByName(groupName);
currentContext.load(group);
var groupUsers = group.get_users();
currentContext.load(groupUsers);
currentContext.executeQueryAsync(OnSuccess, OnFailure);
function OnSuccess(sender, args) {
var userInGroup = false;
var groupUserEnumerator = groupUsers.getEnumerator();
while (groupUserEnumerator.moveNext()) {
var groupUser = groupUserEnumerator.get_current();
if (groupUser.get_id() == currentUser.get_id()) {
userInGroup = true;
break;
}
}
OnComplete(userInGroup);
}
function OnFailure(sender, args) {
OnComplete(false);
}
}
</script>
Display/View Mode
Edit Mode
-Thank you again for any help you can provide