Sunday, October 19, 2014

Calculate days difference in Dataview webpart

Share/Save/Bookmark

To calculate days difference from 2 date time type fields in XSLT, hidden function DateTimeTick from ddwrt can be used as below,

number((number(ddrwt:DateTimeTick(string(@MeetingStartDate))) - number(ddwrt:DateTimeTick(string(@MeetingEndDate )))) div 864000000000)

 Subscribe

Handle case insensitive in XSLT

Share/Save/Bookmark

We may be looking for functions like ToUpper or ToLower but Translate is the function given in  XSLT.

<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name ="Rows" select="/dsQueryResponse/Rows/Row[contains(translate(@UserName,$uppercase,$lowercase),'smith')]" /> 

Do not forget to include single quotes for lowercase/uppercase variables.


Subscribe

Form was customized not working with attachment


Share/Save/Bookmark

Are you troubled with this error? then 99% of chance that you have done something very similar to what i did, building a custom list form(new/edit) where custom list form(dataform)  webpart is added. Also, i believe this is happen to be in only in SharePoint 2007(did not test in 2010/2013).

So when a custom list form webpart is added in the sharepoint designer, it supposed to work as is without any customizations but attachment functionality is broken as it was never completely built. MSFT has released a fix for it. There is a XSLT code snippet you need to copy from here to get this fixed, its pretty straightforward.


Subscribe