Home
Our Work
Services
Small Business Intranet
Samples
Training
SharePoint
Hosting
    
dataBridge Blog

dbWeb > Blog

 dataBridge Blog

More Fun with Date Math in XSLT 1.0
We've got another post from Peter Hill, Solutions Architect, on XSLT math. I know! I didn't go into math, so this is all Peter here. I thank my lucky stars for people who love date math. Peter!
 
Having previously blogged about how fun it can be to work with dates in XSLT 1.0, I thought we'd revisit some of that math
 
Of course in version 2.0 there is a “DateDiff” function that will take the inputs as actual dates and calculate the difference (very handy for determining how far something is away when given a date).  Alas, SharePoint 2010 is still using version 1.0 so I had to do some creative coding and use of variables to achieve the same functionality.
 
We recently had a client that wanted to be able to input a Due Date into a SharePoint date field and then color code that column based on how many days were left until the item was due.  Criteria were as follows: less than 3 days = red, 4 to 7 days = orange, 8 to 28 days = yellow, and anything over 29 days = red.
 
 
First, I  had to break out the today function into year, month and day variables, and then do the same thing with the given Due Date field from the SharePoint list.  Once we had those variables, I needed just a couple more to determine what month it is and how many days are in that month, and then one to calculate the number of days until the Due Date. 
 
The complexity camein when a date falls towards the end of a month or year and the due date is in the next month.  I also had to make sure to factor in leap years so calculations would be right even every fourth year!  This was a fun one to figure out and do some coding. 
 
Here is the xsl:template code below for the cell that contains the due date from within the XSLT List View Web Part.
 
XSL Template code for the Due Date Column of the SharePoint list:
 

<xsl:template name="FieldRef_printTableCell_EcbAllowed.Due_x0020_Date" match="FieldRef[@Name='Due_x0020_Date']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">

                <xsl:param name="thisNode" select="."/>

                <xsl:param name="class" />

 

 

<!—First define the variables that separate out the dates and make them numbers so can do math on them -->

                <xsl:variable name="CurrentMonth" select="number(substring-before(ddwrt:FormatDate(ddwrt:Today(),1033,1),'/'))"/>

                <xsl:variable name="CurrentDay" select="number(substring-before(substring-after(ddwrt:FormatDate(ddwrt:Today(),1033,1),'/'),'/'))" />

                <xsl:variable name="CurrentYear" select="number(substring-after(substring-after(ddwrt:FormatDate(ddwrt:Today(),1033,1),'/'),'/'))" />

                <xsl:variable name="DueMonth"  select="number(substring-before($thisNode/@Due_x0020_Date,'/'))"/>

                <xsl:variable name="DueDay" select="number(substring-before(substring-after($thisNode/@Due_x0020_Date,'/'),'/'))" />

<xsl:variable name="DueYear" select="number(substring-after(substring-after($thisNode/@Due_x0020_Date,'/'),'/'))" />

 

<!—Then define a variable for the number of days in the current month…keeping in mind leap years every four years. -->

                <xsl:variable name="DaysinCurrentMonth">

                                                <xsl:when test="($CurrentMonth = 1) or ($CurrentMonth = 3) or ($CurrentMonth = 5) or ($CurrentMonth = 7) or ($CurrentMonth = 8) or ($CurrentMonth = 10) or ($CurrentMonth = 12)">

                                                                <xsl:value-of select="number(31)" />

                                                </xsl:when>

                                                <xsl:when test="($CurrentMonth = 4) or ($CurrentMonth = 6) or ($CurrentMonth = 9) or ($CurrentMonth = 11)">

                                                                <xsl:value-of select="number(30)" />

                                                </xsl:when>

                                                <xsl:when test="((($CurrentYear mod 4) = 0) and ($CurrentMonth = 2))">

                                                                <xsl:value-of select="number(29)" />

                                                </xsl:when>

                                                <xsl:otherwise>

                                                                <xsl:value-of select="number(28)" />

                                                </xsl:otherwise>

                                </xsl:choose>

                </xsl:variable>

 

<!—Then calculate the days until it is due (didn’t really care about the actual number of days, just if it fell in the ranges that determine the color coding) -->

                <xsl:variable name="DaysTilDue">

                                <xsl:choose>

                                                <xsl:when test="(($CurrentYear = $DueYear) and ($CurrentMonth = $DueMonth))">

                                                                <xsl:value-of select="($DueDay - $CurrentDay)" />

                                                </xsl:when>

                                                <xsl:when test="((($CurrentYear = $DueYear) and ($CurrentMonth &gt; $DueMonth)) or ($CurrentYear &gt; $DueYear))">

                                                                <xsl:value-of select="number(0)" />

                                                </xsl:when>

                                                <xsl:when test="(($CurrentYear = $DueYear) and (($CurrentMonth + 1) = $DueMonth))">

                                                                <xsl:value-of select="(($DaysinCurrentMonth - $CurrentDay) + $DueDay)" />

                                                </xsl:when>

                                                <xsl:when test="((($CurrentYear + 1) = $DueYear) and (($CurrentMonth - 11) = $DueMonth))">

                                                                <xsl:value-of select="(($DaysinCurrentMonth - $CurrentDay) + $DueDay)" />

                                                </xsl:when>

                                                <xsl:otherwise>

                                                                <xsl:value-of select="number(29)" />

                                                </xsl:otherwise>

                                </xsl:choose>                  

                </xsl:variable>

<td align="right">

 

<!—Finally could just use my DaysTilDue variable defined above to set the conditional formatting! -->

<xsl:attribute name="style">

                <xsl:if test="($DaysTilDue &lt;= 3)">color: #FFFFFF; font-weight: bold;  background-color: #CE2121;</xsl:if>

                <xsl:if test="(($DaysTilDue &gt; 3) and ($DaysTilDue &lt; 8))">color: #FFFFFF; font-weight: bold;  background-color: #DD6B00;</xsl:if>

                <xsl:if test="(($DaysTilDue &gt; 7) and ($DaysTilDue &lt; 29))">color: #000000; font-weight: bold; background-color: #F5E300;</xsl:if>

                <xsl:if test="($DaysTilDue &gt;= 29)">color: #000000; font-weight: bold;  background-color: #B1D000;</xsl:if>

</xsl:attribute>                               

                                                               

                <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">

                <xsl:attribute name="height">100%</xsl:attribute>

                <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>

      </xsl:if>

                <xsl:attribute name="class">

                <xsl:call-template name="getTDClassValue">

                                <xsl:with-param name="class" select="$class" />

                                <xsl:with-param name="Type" select="@Type"/>

                                <xsl:with-param name="ClassInfo" select="@ClassInfo"/>

                </xsl:call-template>

      </xsl:attribute>

      <xsl:apply-templates select="." mode="PrintFieldWithECB">

        <xsl:with-param name="thisNode" select="$thisNode"/>

      </xsl:apply-templates>

    </td>

  </xsl:template>

Make a hyper link to a modal Pop-up form (SharePoint 2010)
Today we've got another quick tutorial from Dylan Skinner, one of our Branding Experts. It's one of those quick easy solutions that you can use in SharePoint Foundation to take your site to the next level. Now, Dylan!
 
 Have you ever wanted to make a link to a display, edit or new form in one of those pop-up windows, instead of just linking to a separate page? Well it is actually quite simple to do. All I have done is gone into a list and inspected the “add new item” link and copied the code. Then from there I just made a few changes, of course this could be done many different ways, but this is what I have done, and it works nicely for my scenario.

In the yellow highlighted area is where I replaced the existing URL with my new URL in between the “&quot;”

Note: My URL I am using here is for already existing list items. You can also use this for creating new items. You can have a user click on a button that will open a new form for them to fill out.

<a href="" target="_self" onclick="javascript:NewItem2(event, &quot;/site/test/Lists/Test
Announcements/DispForm.aspx?ID={@ID}&quot;);javascript:return false;">This is where text/img goes</a>
 
You can use this code and it should work for you, or you can go inspect the code yourself using IE developer tools, Fire Bug, or viewing page source, then make necessary adjustments to make it work.
 
Reminder: SharePoint Saturday Atlanta -- This Saturday
For those of you that are local to the south east area (or anyone who wants an excuse to visit) we will be at the SharePoint Saturday in Atlanta on May 7th. That’s THIS Saturday. 

What's SharePoint Saturday Atlanta?
SharePoint Saturday is a free, community-focused SharePoint event dedicated to educating and engaging members of the local SharePoint community.  SharePoint Saturday draws upon the expertise of local SharePoint IT professionals, developers, architects, and users who come together to share real world experiences, lessons learned, best practices and general knowledge with other individuals.

There’s a ton of great stuff going for everyone that is involved in SharePoint from developers and designers to project managers and business owners. There sessions that focus on Branding, Business Intelligence, End User Experience, Development, and Architecture.

There is still time to register, so if you’re interested you can go here.
 
We’ll be there in our blue dataBridge shirts, so stop one of us and introduce yourself!
SharePoint Item Level Permissions 2010 & 2007
Today we've got a brief look at permission settings in 2010 and 2007 environments, specifically item level permissions which can be useful when you need to permission off items between users, but managers, owners and approvers need to see everything on the list. Matthew, one of our Development and Branding Experts has our quick and easy tutorial.
 
Item level permissions keeps end users from seeing each other’s items but let approvers or managers see everything for that list based on an advanced settings and custom list permissions. Users with “Manage List’ permissions would be able to see all items regardless of this setting. (Ed Note: That's the key difference! How you can check to make sure your managers, approvers, etc. can see all the items in a list)
Item level permissions: 
  •  allows users to control ownership of their items.
  • hides items not created by the current user who does not have “Manage List” Permissions.
  • is only available to Lists but not to Document Libraries.
  • doesn't use unique permissions but some other mechanism.

In the advanced list settings we can set item-level permission to “Only their own” This will break the parent permissions for the list and let us give unique permission to users or groups.

 
2007
 
2010
 
 
Now that the list has been setup with Item Level Permissions we need to set custom permissions for the end-users and managers of the list we are working with.
 
1. End Users: should have Read, Add, Delete Permissions.
2. Managers/Approvers: should have Read, Add, Delete & Manage List Permissions

 
News Wrap Up Friday April 29th

Ok I spent part of this morning looking for a way to tie the SharePoint news in with the marriage of William and Kat, and no such luck. So I don’t have a reason to post pictures of the MILLION people that turned out to watch the royal wedding. Oh well.

I did find this about Microsoft’s London offices, where BrightStar will be a presenting a briefing, “Beyond the Firewall with SharePoint 2010” on May 12th. Almost as exciting as a wedding.

Ok in more SharePoint news...

Colliers International, a real estate firm based in Seattle needed a way to connect their experts who operate all over the globe. They went looking for a social collaboration system, and decided to use SharePoint.  

In the Cloud news (why  do I always hear a low rumbling summer thunder storm noise when I type that?): Microsoft has opened up Office 365 to the public for beta testing. They are charging $6 per month for small business use.

 

Here’s a good look at the pros and some cons of the Cloud 

Here’s some more information about the cloud, that UK adoption of SharePoint 2010 and could services has been slower than the rest of Europe.

In the wild world of free web parts, SharePoint Project Progress Monitor has been chosen by SharePoint consultant and founder of SharePoint Village as the finalist web part in The Favorite Free SharePoint Web Parts / Add-ons(http://www.sharepointboost.com).

 

Looking for a Network Engineer!
News! dataBridge is hiring! We are currently looking for a Network Engineer to join our team here in Asheville North Carolina located in the Great Smoky Mountains. (The picture is of our fair city!)

We are looking for versatile team player with excellent communication skills who has a high degree of self-motivation and direction with commitment and integrity. Ability to multi-task and strong analytical and problem solving skills are a must. (We like to stay busy!)  Generous health and dentail insurance along with vacation benefits.

Qualified applicants should have experience in MS SQL 2008, Active Directory, IIS6, IIS7 and DNS .NET framework SSL certificates. Primary job will include installing and configuring new servers with SharePoint through PowerShell scripts. SharePoint experience is not required, we will be willing to train the right person.
 
You can check out the full job description here.
 
Email your resumes to Michael@getsharepoint.com
News Wrap Up: April 22, 2011

It’s a pretty light news week for us, so I thought I take a moment for a quick announcement.

For those of you that are local to the south east area, dataBridge is planning on having a booth at the next SharePoint Saturday in Atlanta on May 7th.  You can learn more about the event here and register here.

We are super pumped to be attending, and there will be about 8-9 of us there walking around in our Carolina Blue T-Shirts. Stop by and say hello!

In more local news, the City of Durham North Carolina is partnering with Northridge to build and deploy an enterprise-wide intranet portal and public-facing internet site on SharePoint 2010. They are planning on leveraging SP 2010 technology to enhance collaboration and communication.

In our continued reporting of the cloud, here’s the darker side. VARs still want to know if and how they can make money from the Microsoft-hosted service.

On the anniversary of the BP oil disaster, a disturbing article from Computer World UK on the BP SharePoint System that has been linked to the Deepwater disaster that happened in the gulf one year ago. It calls attention to the new safety division at BP and their efforts to create a safe, reliable system for BP’s global operations. If anything it’s important to remember that IT is crucial to more than just smooth internal operations, it is bigger than you think.

Why dataBridge? Another Point of View
Hello there readers! I’m Dylan Babb associate producer here at dataBridge and your friendly neighborhood blog editor! We’ve been kicking around a few topics for our blog and someone asked me a great question: What makes dataBridge different? Why do clients come to us  and why do they stay? I’m going to have a few folks answer this question in the blog, but I thought I’d throw my own two cents out there.

I could absolutely give you the full sales pitch right here right now. I could go on about how our narrow focus on SharePoint makes us unique in the market. I could go on about how knowing the ins and outs SharePoint give us an edge over anyone else. I might trot out our credentials and parade our team of experts.  But would you like to read a customer service pitch? Probably not. Honestly, I think dataBridge is your go-to vendor for SharePoint services because it’s an awesome place to work.

Yes, the talent here it top notch. Yes, the customer service here will keep you coming back. But really this is a fantastic team of people who I count on as co-workers and friends. Why dataBridge? Because I don’t dread coming to work in the morning, and my guess is you won’t dread working on your SharePoint project if it means working with this team.

Think your new SharePoint project has to be the black cloud hanging over your head? Think again. I like my team; I stand by my team. That’s dB. 
A Twist on Permissions
Today, we’ve got another great post from Billi our administrative diva and go-to woman for SharePoint support.  Permissions in SharePoint can be quite tricky and it’s easy to get lost in all the definitions. Thankfully Billi is here help sort some if it out, and show us how to keep all handle on permissions. Billi!
 
I recently had an opportunity to set custom permissions for a client with such specific instructions that I questioned whether or not it could be done out of the box. (It can!)

In this scenario a group of external users log in to a corporate intranet where their only permissible access was narrowed down to one folder and one document within that folder.  This in itself – not so terribly difficult. Yet the client also added that the users need the ability to “add documents” to the permissible folder. Simply creating a new permission level with the added ability wasn’t enough.  Unfortunately when you  grant users the ability to “add” the “view all” functionality is automatically assigned.  And it this case, the group needed to be restricted from viewing any other folder or document on this page, save the one they were assigned. Ugh!

The client had two choices:  They could pay a hefty price for a custom webpart which granted the request functionality, or, they could grant the group “contribute” rites.  Yes, in doing so the group would be subject to seeing and accessing all other information on the page… that is until I removed the group from every individual permission settings associated with each document and folder. For example, each document and folder has its own permission settings, I simply granted the group access to the page, while manually removing access to every document or folder posted to that page.  This required tweaking the permission settings to everything posted on the page, by simply selecting a folder or document, and removing said group from associated permission settings.   Cumbersome, yes, but effective.  We were able to meet the requirements and save the client money with this work around. 
1 - 10 Next

 ‭(Hidden)‬ Admin Links