Hide columns in SharePoint List using multiple Content types - Netwoven

Hide columns in SharePoint List using multiple Content types

By Ravi Chandra  •  May 16, 2017  •  10038 Views

Hide columns in SharePoint List using multiple Content types

In SharePoint world one of the most of common business requirement is to show different fields for different set of users. You can partially achieve this using custom views and provide links using audience feature. However, this will not hide columns while creating a new item.

Let’s say you have 2 set of user’s employee and supervisor. In the New form, you want to hide the fields related to Supervisor. When Supervisor edit the same item, they should see all the fields including the fields related to supervisor. If your requirement is just to hide the columns and not to secure them, you can use multiple Content types approach.

Let’s create 2 Content types with some columns in them. As you can see I have added the same columns in the both Content types except Supervisor Comments column.

Hide columns in SharePoint List using multiple Content types

Create a custom list and add the 2 Content types. Hide the OOB Item Content type and Supervisor Content type as we don’t use them while creating the new Item.

Hide columns in SharePoint List using multiple Content types

Open the SharePoint List in SharePoint designer and add a new SP2013 workflow. Make sure you trigger this workflow on Item Added event. In the workflow, add an “update item” action. Set the Content type as Supervisor CT.  Optionally you can add additional actions like emailing Supervisor, logging etc. Save and Publish the workflow.

Hide columns in SharePoint List using multiple Content types

While you are in SharePoint Designer, lets add a custom edit form for Supervisor Content type and add an Edit button on the ribbon. We will mask this button so it is visible to only to Supervisors.

Step1: Adding custom edit form for Supervisor.

Click on New button in the Forms section and add a new Edit Form with the below settings.

Hide columns in SharePoint List using multiple Content types

Open the newly created edit page in Advance mode and hide the workflow columns. We don’t need them.

Hide columns in SharePoint List using multiple Content types

Step 2: Adding Edit link on the Ribbon using Custom Action.

In SharePoint designer click on Custom Action and select Display Form Ribbon.  Call it as “Supervisor Edit” and set the URL to the edit URL that was created in the above step. Add an appropriate image and in the Rights mask field add “DeletelistItems”. With this mask, we are telling SharePoint show this icon only for users who has delete permission on items.  You can choose any other mask option. Click here to find other options. Save all the changes and exit the SharePoint Designer.

Hide columns in SharePoint List using multiple Content types
Hide columns in SharePoint List using multiple Content types

Now we need to create a custom permission so that “Supervisor Edit” button shows only for Supervisors. Click on “Site Permissions” and copy OOB Contribute permission. Give it a name Contribute-No Delete. Retain everything except “Delete List Items”. Create a group and assign the new permission we created in the previous step. Add all the employees to this group.

Hide columns in SharePoint List using multiple Content types

Go to the “List Settings” and break permission for our custom list. Delete all the groups except OOB owners group and the new group created in the previous step. In the Owner group make sure you have the supervisor names.

Login and create a new item. You will see all the fields except Supervisor comments. Submit the form.  SharePoint Designer workflow triggers and changes the Content type to Supervisor Content type. When Supervisor opens the item in display form, they will see an additional button in the ribbon for editing the list item. This link is visible only to Supervisor and it takes them Supervisor edit form.

Employee View:

Hide columns in SharePoint List using multiple Content types

Supervisor View:

Hide columns in SharePoint List using multiple Content types
Hide columns in SharePoint List using multiple Content types

Optionally, using JavaScript you can make few more changes like hiding OOB edit button or making the some of the fields read only.

Hope this helps someone out there.

Leave a comment

Your email address will not be published. Required fields are marked *

Dublin Chamber of Commerce
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Partner
Microsoft Fast Track
Microsoft Partner
MISA
MISA
Unravel The Complex
Stay Connected

Subscribe and receive the latest insights

Netwoven Inc. - Microsoft Solutions Partner

Get involved by tagging Netwoven experiences using our official hashtag #UnravelTheComplex