0

I have a list in SharePoint which has field status. Status has 3 options. I want that when normal user add item he should be able to see only 1 value in dropdown like pending. But user added in admin group (SharePoint group) can see all 3 values. Can someone help to acheive this?

1

You can do this by using a separate list for the status options which is added as a lookup column in your main list.

Using the list item permissions in the separate status options list you can change which items will be visible to whom. This will be reflected in the lookup column.

Example steps:

  1. Create a (custom)list called "Status options"
  2. Add a list item to "Status options" for each of the statusses.
  3. Edit permissions for the items in the "Status options" list that you only want the admin to be able to use.

    Choose not to inherit permissions from the parent list for these items, then edit the permissions so that only an admin would be able to view the item.

  4. In the main list (the one you already had), create a new column of type "lookup". Set it to find values in the "Status options" list.

    This will result in the situation you wanted because of the way SharePoint security works. SharePoint will only show lookup items in the dropdown that the current user has permission to see.

--

Or using JavaScript, jQuery and the SPServices library(newest version will do)

<script type="text/javascript" src="http://gszajnb756:2014/sites/BM/FormServerTemplates/jquery.SPServices-0.7.2.min.js"></script>
<script type="text/javascript">
var adminGroup = "admin group";
var columnName = "Initiative Type" //The name of the SharePoint column
var hideInDropdown = "FRP" //The value of the dropdown item you want to show

var adminUserID = $().SPServices.SPGetCurrentUser({fieldName: "ID"}); //Get ID of current user
$().SPServices({
    operation: "GetUserCollectionFromGroup",
    async:false,
    groupName: adminGroup,
    completefunc: function(xData, Status) {
        var adminUser = $(xData.responseXML).find("User[ID='"+adminUserID+"']");//Find all users in admin group matching current users ID
        if(adminUser.length == 1){//Found a user, so user is admin
            //User is admin, do nothing
        }else{
            //User is not admin, filter dropdown
            var dropdownControl = $("select[title='Initiative Type']"); //Find the dropdown
            $("option[value!='"+hideInDropdown+"']",dropdownControl).remove();//Remove all options not matching the value to be shown
        }
    }
});
</script>

Though I would not recommend doing this with JavaScript when there is an out of the box solution.

  • Hi , Can i do it by javascript or jquery, if you can provide me code – Brishal Mar 23 '15 at 6:16
  • I edited the answer with a JavaScript solution. – Jan Jouke Tjalsma Mar 24 '15 at 7:59
  • Thanks, can you let me know the which SPservices version i need to download and attach or i just need to provide url "path/to/SPServices" – Brishal Mar 24 '15 at 14:39
  • @user21081 the newest version should do the trick – Jan Jouke Tjalsma Mar 25 '15 at 18:48
  • Hi @Jan, I am using below script. Please let me know where i am doin wrong. My sharepoint group name in "admin group" , field name is initiative and have to hide option "FRP". – Brishal Mar 30 '15 at 7:12
2

You should create a custom form for this.

Another option is to edit the default new/edit forms and add a Script Editor WebPart. Inside that you should use JSOM or SPServices to find whether the current user is Admin. Then using JavaScript remove or add Option Tag's.

  • Can you provide me the code – Brishal Mar 20 '15 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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