Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SPO Hide column on DisplayForm for a specific group permission

$
0
0

Hello everyone!

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 get invisible on all groups permission not for the specific group that i have mentioned in the code. Also when i have removed the code the column is not displaying anymore.

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/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)
  {
         //To Hide Column Header
document.querySelector("div[name^='Comments']").parentElement.style.display = "none";

// To Hide all rows for the Comments column
var tdElementsNodeList = document.querySelectorAll("td[class^='ms-vb-lastCell']");
for(var i = 0; i < tdElementsNodeList.length; i++) {
    tdElementsNodeList[i].style.display = "none";
}      
  }
     }
  });
});</script>

What would be the issue in my code?

Any help will be greatly appreciated.
Thank you!

    

Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>