Archive for SharePoint Designer 2007
Performing Date/Time Calculation in DVWP Using XSL
Posted by: | CommentsSharePoint Data View Web Parts (DVWP) may be leveraged to use complex conditional logic using XSL. Such an example would be to highlight List Items in the DVWP that meet certain date/time criteria. The following example will show how XSL may be leverage as a simple and robust solution.
Case:
New tasks (i.e. List Items created within the last 30 minutes) in a User’s “My Tasks” DVWP are highlighted to bring attention to these high priority items.
Undesireable Solution:
Use a declarative workflow to check if the task is no longer new and reset a new ”flag”. XSL will check the “flag” when the DVWP renders and display tasks appropriately.
The workflow would follow the logic:
- Start on Item creation
- Pause for 30 minutes
- Set hidden boolean field value (isNew) to false
The DVWP then uses XSL to check the value of isNew to set the CSS class of a TR, TD, or some other HTML DOM element:
<xsl:if test=”@isNew = 1″><xsl:attribute name=”class”>newTask</xsl:attribute></xsl:if>
This solution is not optimal as a long-term workflow runs on every List Item. As a result, numerous workflows may be running on the server causing decreased server performance.
Solution:
Use XSL to check if a Task is new and set the CSS class appropriately when the DVWP renders.
Logic
For simplicity of the XPath expression, a task may be considered new if both of these conditions are true:
- The date of creation is the current day (i.e. today)
- The time of creation occurs less than 30 minutes before the current time (i.e. now)
(This logic will not handle Tasks assigned from 23:41 to 23:59 as new after 00:00 of the next day. Such Tasks may be handled with a seperate XPath expression to properly determine their new condition.)
Show Elapsed Modified Time in a Document Library
Posted by: | CommentsIntroduction
The requirement has come to fruition to see the elapsed time from the “Modified Date” to “Now” on a reports document library. This is not possible in a calculated value unfortunately do to [Today] and [Me] values being consumed in a calculated value are considered “Volatile” by SharePoint out of the box. These use the core MOSS/WSS functions and since the list is 100% dynamic it doesn’t pull session or current state information before loading the list on page load. Every possible solution was attempted prior to using this custom solution. Although this is all “client side” customization all methods of using out of the box methods were tried prior to this solutions development, the downfall being that even when [Today] was able to be used in a calculated value it did not record the time, only the current date.
Required Items
This solution involves slight modification of Meta Data through a simple SharePoint Designer workflow, a short JavaScript function, and the creation of a “Last Updated” field that is a Date and Time field. Below are step by step instructions with screen shots of how to properly customize any List or Document Library to use this functionality. SharePoint Designer, .NET Frame Work 3.5, and WSS 3.0 are required to implement this solution.
Elapsed Time
Create or open an existing document library and go to settings.

Figure 1 Document Library Settings
Click Create Column

Figure 2 Create Column
Name the Column “Last Updated” (Red) and make it a Date & Time column (Blue)

Figure 3 Configure Column
“Versioning” Update
Posted by: | CommentsSo the customer came back with a change to the “Versioning” request which was instead of Displaying the date to display the “Version” count. This has lead me down an interesting change of the workflow which included the addition of a List to hold the version count as well as a calculation in the work flow which is no a couple of steps longer. The “ChangeTitle” step was not changed at all however the “ChangeName” field was changed due to the numbering system rather than the date. I also had to change the NameDate Field to be the NameCount Field which changes the file name to “%FileName%-%Version #%.” The custom list for the version number is also going to be used to assist fellow MSS employee Chris Lincoln in creating a JavaScript Mouse over in the Document Library showing the Description of each grouping or reports by title, which in itself will be a pretty cool blog entry for next week! Please see my previous blog post here to get the background of this issue/resolution.
The Document Library drives this Workflow not the List.
As seen in the previous blog, Step 1 is the ChangeTitle step and this copies the File Name into the Title Column, the rationale was to maintain unique file names but keep the documents grouped by non-unique Titles.
Step 2 is new and it is the “CreateListItem” step. This creates the item in the list if it not already there. Validating that it is not there maintains only one record in the List while allowing for multiple records in the Library. I validate it off of the current item (Document) title but it ensures that there is no such record in the List which maintains an accurate “Version” count. Once this validation has completed the list Item is completed, if there is already an item with like Title in the list it skips to Step 3 which sets the Version count. The Item is created the Title is copied from the Current Item (Document) and the Version Count is set to 0. Please see the Screen Shots Below for “CreateListItem” Step.
Step 3 adds 1 to the current version # in the List. If this is a new document it becomes Version 1, if it is an old document it is version x + 1. We will use this field to create a variable to add to our New Calculated value we are calling this step “SetCount” and it updates the lists count and stores a “calc” variable. The calc variable set in step three will enable the “Versioning” as seen in Step 4. Please see the Screen Shots Below.
Step 4 has been modified slightly, as before the pause was to give time for the File Name to enter into the calculated value, since this step actually places the “Count” Value into the Item and Calculated Values pull from the Item itself the pause has been moved to below the input of the calc variable into the “Count” field on the current item. The pause allows for the calculated value NameCount to wait for the Count variable to be added which takes about 30 seconds, however 1 minute is the shortest pause possible in SharePoint Designer. Please see the screen shot below:
There will be a third post regarding this effort as far as adding the JavaScript mouse over tool tips for the groups by title in the default view.
SharePoint Designer 2007 “failed to load the workflow”
Posted by: | CommentsTo resolve the error “failed to load the workflow” when opening a declarative workflow in Microsoft SharePoint Designer 2007, please follow the steps provided below:
- Close Microsoft SharePoint Designer 2007
- If using Microsoft Windows XP, navigate to the directory:
C:\Documents and Settings\[USER NAME]\Application Data\Microsoft\SharePoint Designer\ProxyAssemblyCache\
If using Microsoft Windows Vista, navigate to the directory:
C:\Users\[USER NAME]\AppData\Roaming\Microsoft\SharePoint Designer\ProxyAssemblyCache\ - Delete all folders with the naming convention 12.x.x.xxxx
- Start Microsoft SharePoint Designer 2007 and open the desired workflow
Please be aware that it may be necessary to perform these steps multiple times.
UPDATE (09/28/2009):
A possible cause of this behavior may be related to the use of custom activities within the workflow. If the above solution does not resolve the issue, it may be necessary to redeploy/reinstall any custom activities that the workflow may reference.









