Search code examples
sharepointsharepoint-2010

check if user has permissions to add items to the list in a SharePoint DVWP with XSLT


Is it possible to check if a user has permissions to add items to the list in a DVWP when rending with XSLT?

The idea being to see if the user has access to add and if they do add a link to the newform page.


Solution

  • You can do it by this XSLT function ddwrt:IfHasRights(XX) where XX is permission mask. Like this:

    <xsl:if test="ddwrt:IfHasRights(16)"><tr>
    <td width="190px" valign="top" class="ms-formlabel"><H3 class="ms-standardheader"><nobr>Entry Status</nobr></H3></td>
    <td width="400px" valign="top" class="ms-formbody"><SharePoint:FormField runat="server" id="ff8{$Pos}" ControlMode="New" FieldName="Entry_x0020_Status" __designer:bind="{ddwrt:DataBind('i',concat('ff8',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Entry_x0020_Status')}" /><SharePoint:FieldDescription runat="server" id="ff8description{$Pos}" FieldName="Entry_x0020_Status" ControlMode="New" /></td>
    </tr>
    </xsl:if>
    

    More detailed description can you find e.g. here. But be aware that it works fine for SP2010, SP2013 but not in SP Online.