Friday, 12 November 2010

Task List Displaying all my tasks

During a recent engagement with a client I worked under the constraints of only having Site Owner access and nothing could be developed beyond using SharePoint Designer.  This presented a learning opportunity and resulted in an interesting way to group and display tasks.
The initial problem I found with displaying a task list is you can either show a user’s tasks or tasks a user is a group of.  But out of the box you can’t show both and a quick look up found a CAML query from a former colleague Martin Hatch that helped with this. 
<Where>
  <Or>
    <Eq>
      <FieldRef ID='Assigned To' />
      <Value Type='Integer'><UserID/></Value>
    </Eq>
    <Membership Type='CurrentUserGroups'>
        <FieldRef Name='AssignedTo' />
    </Membership>"
  </Or>
</Where>
Next the client wanted to show a Red, Amber or Green (RAG) rating on a task as an image rather than text.  So creating four columns which are calculated fields based on due date calculate for us the RAG date a task changes status.  Then a quick SharePoint Designer workflow process that uses this RAG date and updates a RAG value in a hidden column allows us then to display the status of tasks.
To finish this off some XSL on the WebPart that takes the text value displayed and replaces this with an image based on the colour and we have a task list that shows the status of a task in a nice to view display for a user’s tasks and tasks a user is a member of.
<xsl:template name="FieldRef_body.RAG" ddwrt:dvt_mode="body" match="FieldRef @Name='RAG']" mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="thisNode"
select="."/><span>

<xsl:choose><xsl:when
test="normalize-space($thisNode/@RAG) = 'Red'">
<img src="/SiteAssets/red-button.png" alt="Red"/>
</xsl:when><xsl:when test="normalize-space($thisNode/@RAG) = 'Amber'">
<img src="/SiteAssets/amber-button.png" alt="Amber"/>               </xsl:when>
<xsl:otherwise>
<img src="/SiteAssets/green-button.png" alt="Green"/>
</xsl:otherwise>
</span></xsl:template>

No comments:

Post a Comment