I would like to display certain meta data fields in the edit form based on the value of a fields.
我想根据字段的值在编辑表单中显示某些元数据字段。
Example: Users upload a document to the Doclib to be approved by there manager. They are allowed to change the meta data Name,Case No, Location until the item is approved by the manager. Once the item is approved I would like to set Name and Case Number to read only.
示例:用户将文档上载到Doclib以由经理批准。他们可以更改元数据名称,案例号,位置,直到该项目得到经理的批准。一旦项目被批准,我想将名称和案例编号设置为只读。
What is the best way to meet this requirement?
满足此要求的最佳方法是什么?
If approved = yes set Name and Case No = Read only Else do nothing.
如果已批准=是设置名称和案例否=只读否则不执行任何操作。
I have tried this method for about 5 hours. I believed this may be different for ModerationStatus. Might require something special
我已经尝试了这种方法大约5个小时。我相信这可能与ModerationStatus不同。可能需要特别的东西
print("<xsl:choose>
<xsl:when test="@_ModerationStatus != '0;#approved'">
<SharePoint:FormField runat="server" id="ff12{$Pos}" ControlMode="Edit" FieldName="Test_x0020_Session" __designer:bind="{ddwrt:DataBind('u',concat('ff12',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Test_x0020_Session')}"/>
<SharePoint:FieldDescription runat="server" id="ff12description{$Pos}" FieldName="Test_x0020_Session" ControlMode="Edit"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@Test_x0020_Session"></xsl:value-of>
</xsl:otherwise>
");
I can get it to work with the other fields but not ModerationStatus. I have also tried changing it to !='0' and !='Approved' and '0;#Approved'. Is there something I am doing wrong?
我可以让它与其他字段一起使用,但不能使用ModerationStatus。我也尝试将其更改为!='0'和!='已批准'和'0; #Approved'。有什么我做错了吗?
Seems like its stuck on 0;#Approved
好像它卡在0上; #Approved
2 个解决方案
#1
1
This can be easily solved with SharePoint Designer.
使用SharePoint Designer可以轻松解决此问题。
- You will need to modify EditForm.aspx for your list
- Hide the default ListFormWebPart (Do not delete it!)
- Insert custom edit item form (more details...)
您需要修改EditForm.aspx作为列表
隐藏默认的ListFormWebPart(不要删除它!)
插入自定义编辑项目表单(更多详细信息......)
Custom form will look exactly the same as the default one, but you will be able to customize it with SharePoint Designer. The code below can be used for default WSS Issues list. It will show Issue title as read-only when Issue Status = Closed.
自定义表单看起来与默认表单完全相同,但您可以使用SharePoint Designer自定义表单。以下代码可用于默认WSS问题列表。当Issue Status = Closed时,它会将Issue title显示为只读。
<xsl:choose>
<xsl:when test="@Status != 'Closed'">
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
<SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="Edit"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@Title"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
You can apply the same logic for your custom lists or/and requirements.
您可以为自定义列表或/和要求应用相同的逻辑。
As usual, you might run to some additional problems. I was not able to get the value of @_ModerationStatus in Data View Web Part. I do not know the exact reason...
像往常一样,您可能会遇到一些其他问题。我无法在数据视图Web部件中获得@_ModerationStatus的值。我不知道具体原因......
Here is a simple workaround:
这是一个简单的解决方法:
- Create a Column in your Document Library
- Create a new in workflow SharePoint Designer.
在文档库中创建一个列
在工作流SharePoint Designer中创建新的。
It should fire when item is changed and copy the value of approval status to newly created column.
它应该在项目更改时触发,并将批准状态的值复制到新创建的列。
You can use the custom column for conditional formatting.
您可以使用自定义列进行条件格式设置。
#2
0
Follow Toni's comments but for your _ModerationStatus field use following XSLT function:
按照Toni的注释,但对于_ModerationStatus字段,请使用以下XSLT函数:
<xsl:when test="not(starts-with(@_ModerationStatus,'0'))">
#1
1
This can be easily solved with SharePoint Designer.
使用SharePoint Designer可以轻松解决此问题。
- You will need to modify EditForm.aspx for your list
- Hide the default ListFormWebPart (Do not delete it!)
- Insert custom edit item form (more details...)
您需要修改EditForm.aspx作为列表
隐藏默认的ListFormWebPart(不要删除它!)
插入自定义编辑项目表单(更多详细信息......)
Custom form will look exactly the same as the default one, but you will be able to customize it with SharePoint Designer. The code below can be used for default WSS Issues list. It will show Issue title as read-only when Issue Status = Closed.
自定义表单看起来与默认表单完全相同,但您可以使用SharePoint Designer自定义表单。以下代码可用于默认WSS问题列表。当Issue Status = Closed时,它会将Issue title显示为只读。
<xsl:choose>
<xsl:when test="@Status != 'Closed'">
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
<SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="Edit"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@Title"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
You can apply the same logic for your custom lists or/and requirements.
您可以为自定义列表或/和要求应用相同的逻辑。
As usual, you might run to some additional problems. I was not able to get the value of @_ModerationStatus in Data View Web Part. I do not know the exact reason...
像往常一样,您可能会遇到一些其他问题。我无法在数据视图Web部件中获得@_ModerationStatus的值。我不知道具体原因......
Here is a simple workaround:
这是一个简单的解决方法:
- Create a Column in your Document Library
- Create a new in workflow SharePoint Designer.
在文档库中创建一个列
在工作流SharePoint Designer中创建新的。
It should fire when item is changed and copy the value of approval status to newly created column.
它应该在项目更改时触发,并将批准状态的值复制到新创建的列。
You can use the custom column for conditional formatting.
您可以使用自定义列进行条件格式设置。
#2
0
Follow Toni's comments but for your _ModerationStatus field use following XSLT function:
按照Toni的注释,但对于_ModerationStatus字段,请使用以下XSLT函数:
<xsl:when test="not(starts-with(@_ModerationStatus,'0'))">