Click here to Skip to main content
12,998,759 members (76,699 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 13 Aug 2014

Hide Fields using Permission Levels in SharePoint using Java Script

, 13 Aug 2014
Rate this:
Please Sign up or sign in to vote.
Hide Fields using Permission Levels in SharePoint using JavaScript


Welcome to a new important tip for all developers where we will hide the form fields based on their permission we require.

So suppose I have a form with 10 fields and I want few of them should be visible only to certain users, so what will I do?

Let’s hit the topic.

  • First, create a group and keep all users you want to have access in all fields in a form in that group.
  • Other users who have access to the form but no access to those special fields can be added anywhere in the site to any permission level.
  • Now in that form, add the following JavaScript code in new, edit as well as view item.
  • For me, I have hidden Status, any comments, reviewed by and Response fields for general users.
  • Now what I am doing is, I am calling sp services to check whether the logged in user is one among my 'Request Team' group.
  • If he is not, he will not be able to view, edit or create the above fields.
  • But if he is one among the users in the group, he will be able to see all other fields as he has special rights to see them.

The code is as follows:

<script type="text/javascript">    
$(document).ready(function () {
$("textarea[title$='Any Comments']").parent('span').parent('td').parent('tr').hide();
$("Select[title$='Reviewed By']").closest('tr').hide();
        operation: "GetGroupCollectionFromUser",
        userLoginName: $().SPServices.SPGetCurrentUser(),
        async: false,
        completefunc: function (xData, Status) {
            if (($(xData.responseXML).find("Group[Name='Request Team']").length == 1)) {
$("textarea[title$='Any Comments']").parent('span').parent('td').parent('tr').show();
$("Select[title$='Reviewed By']").closest('tr').show();

Don’t you think this is a neat job rather than working on Infopath forms and setting up the rules?

Keep learning.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Argentina Argentina
No Biography provided

You may also be interested in...


Comments and Discussions

Questionhow to hide a look up field Pin
Member 130351122-Mar-17 20:13
memberMember 130351122-Mar-17 20:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 13 Aug 2014
Article Copyright 2014 by MANPREET SINGH
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid