I want to hide a column for a specific group permission on Display form.
I have found a jQuery code and I have tried to use it but the column still visible to the user that is on this particular group.
I added the code by:settings --> edit the page --> web part --> script editor.
Here is my code:
<script
src="https://code.jquery.com/jquery-1.10.1.js"
integrity="sha256-663tSdtipgBgyqJXfypOwf9ocmvECGG8Zdl3q+tk+n0="
crossorigin="anonymous"></script>
<script type="text/javascript"
src="mysite/SiteAssets/jquery.SPServices.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function (xData, Status) {
var xml = xData.responseXML.xml;
var flag = ($(xData.responseXML).find("Group[Name='Dev Site Add-ins Members']").length != -1);
if (flag)
{
var feedbackField = $("input[title=Comments]");
feedbackField.parent().parent().parent().hide();
}
}
});
});
</script>
Here is screenshot:
In this screenshot the comments column still visible for this user:
Any idea what I am doing wrong ?
Any help will be greatly appreciated.
Thank you!
$("input[title=Comments]")
). You cannot use the same selector in list view to hide the column.