Hide content type field in edit form in SharePoint Online/2013/2016

This SharePoint customization tutorial, we will discuss, how to hide the content type drop-down which comes in edit form inside SharePoint online task list. The same way we can hide content type field in edit form in SharePoint 2016 or SharePoint 2013.

Recently we were working in a visual studio 2015 workflow, there we have added the various custom content types into the task list in SharePoint.

If you are new to SharePoint visual studio workflow, you can check out Develop SharePoint workflows using visual studio as SharePoint hosted App.

By default whenever a task got created and a user wants to approve/reject the task from the edit form, the content type drop-down appears like below:

sharepoint hide content type field edit form
sharepoint hide content type field edit form

As per the requirement, we need to hide the content type drop-down from the task list edit form.

SharePoint hide content type field edit form

We can hide the content type by using below jQuery code in SharePoint list form.

Either we can put the code inside the Edit form task list or we can also put inside master page in SharePoint.

To put inside the page, Edit the page -> And then add a script editor web part. Inside the script editor web part, put the below code. Once you save the page and refresh it will hide the dropdown.

<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function () {

$("select[id*='ContentTypeChoice']").closest('tr').hide();

});

</script>

Similarly, we can put the code inside a master page. But since when you put the code inside master page, it might hide every list, so I had added one condition like below:

First retrieve the browser URL like : var pageURL = $(location).attr(“href”);

Then if the URL contains the list URL then only it will hide.

if( pageURL.indexOf('/WorkflowTasks/') >= 0)
{
}

The full code like below:

<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function () {
var pageURL = $(location).attr("href");

if( pageURL.indexOf('/WorkflowTasks/') >= 0){

$("select[id*='ContentTypeChoice']").closest('tr').hide();
}

});

</script>

You may like following SharePoint content type tutorials:

Once you put the above code inside the master page, it will hide the content type in the edit form in SharePoint.

sharepoint online hide content type field in edit form
sharepoint online hide content type field in edit form

In this tutorial, we saw how to hide the content type drop-down which comes in edit form inside SharePoint Online/2013/2016 task list.

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bhawana Rathore

Hello Everyone!! I am Bhawana a SharePoint MVP and having about 8+ years of SharePoint experience as well as in .Net technologies . I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools . Now exploring more in SharePoint 2016 :) Hope here I can contribute and share my knowledge to the fullest. As I believe "There is no wealth like knowledge, and no poverty like ignorance"

  • […] Hide content type field in edit form in SharePoint Online/2013/2016 […]

  • >