1

In SharePoint 2013 site, there is a custom list which has a column that should be visible to only one particular SP group.
That column will not be in forms (new/edit/disp) so I don't need hiding it from forms, just in view.
I thought of creating two views and then putting each of them in web part and adding target audiences I could do it, but I am asking if there is some better/nicer way to do this?

2 Answers 2

3

For performance-related reasons, the SharePoint doesn't provide column-level security as OOTB.

The available workarounds

Use the below code to hide a specific column based on a specific group using SPSerevice and JQuery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.js"></script>
<script type="text/javascript">
$(document).ready(function() {

 $().SPServices({
 operation: "GetGroupCollectionFromUser",
 userLoginName: $().SPServices.SPGetCurrentUser(),
 async: false,
 completefunc: function(xData, Status) {

 //If the current User does belong to the group "SharePoint Group Name: HamzaQassas"
 if($(xData.responseXML).find("Group[Name='HamzaQassas']").length == 1)
 {
  // Hide the Column with its order ID in List View (Title=2 ...etc)
  $(document).ready(function(){$('td:nth-child(2),th:nth-child(2)').hide()});
 }
 }
 });
});
</script>

Output

enter image description here

  • Use your mentioned method with multiple views in web part pages and manage Target Audiences
  • Use a 3rd party tool like Infowise.
1
  • Solution 1 was what I thought of.
    – Danilo
    Dec 5, 2017 at 10:44
3

Format the fields using JSLink

(function () {

 var ctx = {};
 ctx.Templates = {};
 ctx.Templates.Fields = {
    "Cost_x0020_Status": { "View": FieldTemplate },
  };
 };
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctx);
    })();

function FieldTemplate(ctx) {
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.