Sharepoint conditional fields in Edit.aspx

I would like to display specific metadata fields in an edit form based on the field values.

Example: users upload a document to Doclib, which must be approved by the manager. They are allowed to change the Name, Case No, Location metadata until the item is approved by the manager. Once the item is approved, I would like to provide a read-only name and case number.

What is the best way to meet this requirement?

If set = yes set Name and Case No = Read-only do nothing yet.


I tried this method for about 5 hours. I figured it might be different for ModerationStatus. Something special might be required

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 other fields, but not ModerationStatus. I also tried changing it to! = '0' and! = 'Approved' and '0; #Approved '. Is there something I am doing wrong?

It seems to be stuck at 0; #Approved

+1


source to share


2 answers


This is easy to solve with SharePoint Designer.

  • You will need to change EditForm.aspx for your list
  • Hide default ListFormWebPart (don't delete it!)
  • Insert your own edit control form ( more ... )

The custom form will look exactly the same as the default, but you can customize it using SharePoint Designer. The code below can be used to list the default WSS issues. It will show the issue title as read-only when Status Issue = Closed.

<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 and / or requirements.



As usual, you may run into some additional problems. I was unable to get the @_ModerationStatus value in the Data View Web Part. I don't know the exact reason ...

Here's a simple way:

  • Creating a column in your document library
  • Create a new workflow in SharePoint Designer.

It should fire when the item changes and the approval status value is copied to the newly created column.

You can use a custom column for conditional formatting.

+1


source


Follow Toni's comments, but for your _ModerationStatus field, use the following XSLT function:



<xsl:when test="not(starts-with(@_ModerationStatus,'0'))">

      

0


source







All Articles