Hide fields in new item menu
-
08-12-2020 - |
Pergunta
I have followed the answer described in Hide list column on new, edit item-OOTB
But what I found is when editing the column from the content type, i found the hidden menu is disabled.
Content type description :
Approved field settings :
Why does this problem occur?
Solução
It happens for Yes/No (check box) column but it is possible to hide it from SharePoint Designer. Follow below steps to hide from Designer.
- Open site in designer
- Click On List/Library from left side
- Click on your list
- Click on edit content type
- Click multiple times (may be it is six times) on your column and then you will get your column in edit mode. Now select the option from drop-down menu.
Outras dicas
Alternative Solution
If you want hide any field from NEW/VIEW/EDIT item Forms. Then you can simply achieve this using SPUtility.js, Its very simple and useful. You can download js file from sputility
Steps:
- Edit NEW/VIEW/EDIT item form in SharePoint UI.
- Add Script editor web part.
Add the following script in Script editor web part.
<script src="/jquery.min.js" type="text/javascript"></script>
<script src="/sputility.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
SPUtility.HideSPField('FieldNameToHide');
});
</script>
Ok & Save the page. Now specified field will not be visible.
If you want to Show that field again then you can use,
<script src="/jquery.min.js" type="text/javascript"></script>
<script src="/sputility.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
SPUtility.ShowSPField('FieldNameToShow');
});
</script>
SPUtility.js is a JavaScript library used to make modifications to SharePoint's list forms (NewForm.aspx, DispForm and EditForm.aspx in a survey, custom list or library). It works with SharePoint 2007, 2010, and 2013 (including SharePoint Online / Office 365).
Here's a little SharePoint PnP function to update a field Hidden setting
function setFieldHidden([string]$inListName,[string]$inContentTypeName,[string]$infieldTitle,[int]$hide1vis0){
$Connection = Get-PnPConnection #assumes you are connected to PnP site.
# Get list content type object
$ListContentType = Get-PnPContentType -list $inListName -Identity $inContentTypeName
$lcFields = Get-PnPProperty -ClientObject $ListContentType -Connection $Connection -Property "Fields"
foreach($field in $lcFields){
if($field.Title -eq $infieldTitle){
$ListContentTypeField = $field
}
}
$ListContentTypeField
# Code to set content type field hidden
$ListContentType.FieldLinks.GetById($ListContentTypeField.Id).Hidden = $hide1vis0
# Update(UpdateChildren – bool), this value indicates whether the children content type(inheriting from this Content Type) needs to be updated. 0 = False, 1 = True
$ListContentType.Update(0)
$Connection.Context.ExecuteQuery()
}