How to hide SharePoint Online content type dropdown in task list edit form using jQuery

This SharePoint tutorial explains, how to hide content type drop-down from SharePoint Online, which comes in edit form inside SharePoint online task list. The same solution will also work for SharePoint 2013 and SharePoint 2016.

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

If you are new to SharePoint workflow development, then check out the below SharePoint workflow tutorials:

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

Hide SharePoint online content type in task list edit form using jQuery
Hide SharePoint online content type in task list edit form using jQuery

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

Hide content type dropdown

We can hide the content type drop-down by using below jQuery code in SharePoint Online/2013/2016.

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

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>

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

Hide content type dropdown in task list edit form using jQuery SharePoint 2013
SharePoint 2013 Hide content type dropdown in task list edit form using jQuery

You may like following SharePoint task list tutorial:

I hope this SharePoint tutorial explains, how to hide SharePoint Online/2013/2016 content type dropdown in task list edit form using jQuery.

Tags: SharePoint hide content type, SharePoint hide content type in the edit form, SharePoint 2013 hide content type in edit form, SharePoint 2013 hide content type field in the edit form, SharePoint online hide content type in task list edit form.

>