குறிப்பு: this was first posted at www.endusersharepoint.com இங்கே: HTTP://www.endusersharepoint.com/2009/11/02/comparing-dates-in-a-data-view-web-part-to-build-a-wss-kpi-in-sharepoint/.
This is yet another blog post on comparing dates in XSL in a data view web part in SharePoint.
This is my scenario:
- I have a custom list.
- The business purpose of the list is to support the idea of a new employee and his/her tasks to be completed within 7 days of starting the job.
- They are in a “warning zone” after 4 days if they have not completed these tasks.
- I want to create a simple dashboard that shows green when they have either completed the task or if they have more than 4 days to complete it.
- I want the dashboard to show yellow if they are in the warning zone.
- I want to to show red if they have not completed the task after the due date.
I borrowed from இந்த கட்டுரை இல் Marc Anderson’s வலைப்பதிவு (http://mdasblog.wordpress.com/2008/02/19/comparing-dates-in-sharepoint-using-xsl/) to get the comparison logic and இந்த கட்டுரை இல் www.endusersharepoint.com for the basic ideas behind the dashboard (http://www.endusersharepoint.com/2008/12/09/visual-indicators-for-the-masses-kpis-in-wss/) written by Toni Frankola.
You should read the supporting blogs, but the implementation goes like this:
- ஒரு உள்ளடக்க வகை உருவாக்க (பத்திகள் + CT)
- Create a custom list and associate it with the content type.
- Create a web part page.
- Add the custom list to the web part page.
- Open up the page in SPD.
- Convert the list to a DVWP.
- Modify the XSL to generate the dashboard bits.
I have two dates: a warning date and a due date. To compare the dates, my xsl does the following:
<XSL:தேர்வு> <!-- When both handbook and policy are signed, we are green regardless of dates. -->
<XSL:எப்போது சோதனை="@Employee_x0020_Handbook_x003F_ = 1 and @Security_x0020_Policies = 1"> <நன்றி src="/_layouts/images/KPIDefault-0.GIF" வயதான="No problems"/> <ஒரு படம்="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ ஐடி}&ஆம்ப்;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</ஒரு> </XSL:எப்போது> <!-- Show amber indicator if we're past the warning date. -->
<XSL:எப்போது சோதனை="ddwrt:FormatDateTime(மாலை(ddwrt:இன்று()), 1033, 'yyyyMMdd') &ஜிடி;= ddwrt:FormatDateTime(மாலை(@TaskDueDate), 1033, 'yyyyMMdd')"> <நன்றி src="/_layouts/images/KPIDefault-2.GIF" வயதான="Overdue"/> <ஒரு பாணி="border: 0px" படம்="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ ஐடி}&ஆம்ப்;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</ஒரு> </XSL:எப்போது> <!-- Show red indicator if we're passed the due date. -->
<XSL:எப்போது சோதனை="ddwrt:FormatDateTime(மாலை(ddwrt:இன்று()), 1033, 'yyyyMMdd') &ஜிடி;= ddwrt:FormatDateTime(மாலை(@Warning_x0020_Date), 1033, 'yyyyMMdd')"> <நன்றி src="/_layouts/images/KPIDefault-1.GIF" வயதான="Warning"/> <ஒரு படம்="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ ஐடி}&ஆம்ப்;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</ஒரு> </XSL:எப்போது> <!-- If we get here, we're earlier than the warning date, so we're green. -->
<XSL:இல்லையெனில்> <நன்றி src="/_layouts/images/KPIDefault-0.GIF" வயதான="No problems"/> <ஒரு படம்="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ ஐடி}&ஆம்ப்;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</ஒரு> </XSL:இல்லையெனில்> </XSL:தேர்வு> |
A few key points from above:
- I tried to compare dates without using the ddwrt functionality and got nowhere. I still don’t understand that. They dates displayed correctly, but both “>” and “<” comparisons always failed. முடிவில், ddwrt came to my rescue (நன்றி, மறுபடி, மருந்து ஆக்கலின் வண்டல்).
- I’m also displaying an [Edit] link to the item. I mainly did this so that I could easily test this out. The link itself may be useful to someone trying to figure it out.
- This is implemented in SharePoint online and works nicely.
- The images I reference in the _layouts directory (/_layouts/images/KPI…) are available out of the box in my environment so they are probably available for you as well.
Here’s a screen shot of what it looks like for me:
</இறுதியில்>
மணிக்கு ட்விட்டரில் என்னை பின் http://www.twitter.com/pagalvin