问题描述
嗨.
我已将SharePoint 2016与最简单的文档库以及自定义ContentType一起使用.
我的ContentType"SAPRecallCT"具有三个字段:newSapID(字符串),标题(字符串),状态(字符串)
I have using SharePoint 2016 with the simplest Document Library with the custom ContentType.
My ContentType "SAPRecallCT" have a three fields: newSapID (String), Title (String), State (String)
其中一个(newSapID)需要通过使用 ShowInEditForm 属性来隐藏.
One of them (newSapID) need to be hidden by using ShowInEditForm properties.
我的动作:
获取对$ web上下文的引用:
Getting the reference to $web context:
$env:SPpath = "${env:CommonProgramFiles}\Microsoft Shared\web server extensions\16\"
[System.Reflection.Assembly]::LoadFrom("$env:SPPath\ISAPI\Microsoft.SharePoint.dll")
$web = Get-SPWeb http://portal/projects;
获取列表:
Getting a List:
$list = $web.GetList("http://portal/projects/SAPRecallLib/Forms/AllItems.aspx");
..然后是ContentType:
..And then ContentType:
$ct = $list.ContentTypes["SAPRecallCT"];
..取一个字段:
.. take a field:
$field = $ct.Fields.GetFieldByInternalName('newSAPId');
..并尝试更改我的字段的可见性:
..and trying to change visibility of my field:
$field.ShowInEditForm = $false;
$field.Update();
在$ field.Update之后,我得到了错误:
after $field.Update i get error:
调用更新"的异常;带有"0"参数:此功能 对于与列表无关的字段不可用.
Exception calling "Update" with "0" argument(s): "This functionality is unavailable for fields not associated with a list.
我做错了什么?
推荐答案
只需直接在列表中获取字段,而不是通过contentype获取
Just Get Field directly on the list instead of getting by contentype
这篇关于如何使用ShowInEditForm属性隐藏/显示自定义ContentType的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!