Archive for the 'SharePoint Customization' Category

03
Dec
10

Conditional Formatting and date comparisons with SharePoint Designer 2010

So here’s a fun one that we at SharePoint Rx were struggling with the other day. 

We were creating a dashboard using the DVWP in SharePoint Designer 2010 and had to perform some date comparisons to control the display of indicators.  If you’ve used SPD in the past, you know that the goal is to NOT write code, but to use the “coding by clicking” capabilities of SPD and allow it to write the code (in this case XSL) to control your conditional formatting.  Every time I use SPD for something like this, I always seem to run into a new problem, even though I know it should be a simple task. 

“Am I the only one with this issue?” he asks.

Here’s the end goal…to display a status indicator for tasks to indicate whether they were completed on time, completed late, not complete and not late, and not complete and late.  You can see the four icons I chose to indicate these statuses. 

image

My “conditions” are as follows:

clip_image001 Status equals “completed” and Due Date >= Completed Date

clip_image002 Status equals “completed” and Due Date < Completed Date

clip_image003 Status not equals “completed” and Due Date >= [Current Date]

clip_image004 Status not equals “completed” and Due Date < [Current Date]

One of the issues you immediately experience is the comparison of date values.  Using SPD, I did an “un-advanced” comparison in my condition statements and never got the correct results.  SPD wrote some XSL like this (I broke it up so it’s a little easier to read):

<xsl:if test=”normalize-space($thisNode/@Status) = ‘Completed’

and

ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@DueDate))) &gt;=
normalize-space(@Completed_x0020_Date)” ddwrt:cf_explicit=”1″>

<img src=”_layouts/images/kpinormal-0.gif” width=”16″ height=”16″ />

</xsl:if>

So we have a “Due Date” that has been operated on by ddwrt:DateTimeTick (see if you can find any documentation on this function) and is returning the number of days from January 1, 1900 comparing to the “Completed Date” in the form “MM/DD/YYYY.”  That doesn’t work!

Sidebar rant…Come on, Microsoft!  The only documentation on the ddwrt namespace is from a non-MS person (Serge van den Oever ) and is from 2005…for SharePoint 2003?

So, let’s look at the “Advanced” condition criteria that does work.

image

We used the completely undocumented ddwrt:DateTimeTick function and applied it equally to both dates.

image

When performing the comparison with [Current Date], here’s what we did.

image

We were successful with using the $Today variable, but I’ve seen others who have also used ddwrt:Today.

image

Here are the criteria for all four conditions.

@Status = ‘Completed’ and ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@DueDate))) >= ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@Completed_x0020_Date)))

@Status = ‘Completed’ and ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@DueDate))) < ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@Completed_x0020_Date)))

$thisNode/@Status != ‘Completed’ and ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@DueDate))) >= ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($Today)))

$thisNode/@Status != ‘Completed’ and ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@DueDate))) < ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($Today)))

Now, I’d like to believe that features in SPD 2010 that were in SPD 2007 were all functioning correctly, but I seem to have lots of problems using the “All formatting visible” functionality.  I found that each time I changed this I must

  • Save the page
  • Press F5 to refresh (sometimes more than once)

Not sure what that’s about or if it’s just one of my settings, but it sure is annoying.

image

Of course, the idea is that you want to make all your conditionally formatted elements visible so you can easily work on them.

image

FYI, if you want to determine which condition applies to which element, you can select the condition and you should notice a highlighting of the element to which the condition corresponds. 

image

Keywords:

Conditional formatting

SharePoint Designer 2010

Date comparison

Data view web part

ddwrt namespace

15
Oct
10

Let’s Make a Clickable Image Map Using SharePoint Designer 2010

…and I do mean Map!

Get your base image and copy it to the clipboard.  I’m going to use a map of the world.

image

On the asset-based navigation in SPD 2010, you’ll need to navigate to an object that will allow you to create an HTML file in it.  Here I’m using Site Pages, but you could also select All Files.  You probably want to save it somewhere so you can modify it later, if need be.

image

Open the file (Untitled_1.html) for editing.

image

Delete the HTML that came with the new page.

image

Paste your image into the page.

image

Click on the map image and then select Format under Picture Tools.  You’ll now have access to the Hotspot tool.  Select either the Polygonal, Rectangular or Circular Hotspot drawing tool.

image

Using your coloring skills you learned in Kindergarten, trace each of the areas you want to hotspot.

image

When you close the polygon, you’ll get a dialog where you can enter the address that the hotspot is linked to.

image

Copy all the source to the clipboard…

image

…and paste it into the HTML view of a content editor web part.

image

You should see it displayed with the regions visible.

image

The finished product.  Hovering over an area will give you "the hand" and clicking will take you to your hyperlink.

image

11
Jul
10

Running the Content Query Web Part (CQWP) on a Team Site Without the Publishing Infrastructure Feature Enabled in SharePoint 2010

I was doing a little monkeying around (read that "book editing") with SharePoint 2010 and decided to see if the similar post I read by Sameer Dhoot was still true in 2010.  If you are missing the CQWP in SharePoint, you’ll find that activating the Publishing Infrastructure feature will fix the problem, as the CQWP is added/enabled as part of the Publishing Infrastructure.  Well, what if you want to use it in a team site for some reason?  Turns out you can still do it.

If you simply export the CQWP from the web part gallery of your publishing site and import it to the web part gallery on your collaboration site, you won’t run into any problems.

image

You can export the web part by clicking the Edit icon and selecting the Export function in the ribbon.

image

The problems will start to occur when you try and use it.  You’ll get errors when your page on which you’ve added the CQWP attempts to render the web part.

image

In this version of SharePoint, there is a Style Library in both collaboration and publishing sites.  The important difference is that the collaboration site Style Library is empty.  This is where the problem resides.  You can either copy the content out of the publishing site style library or, you can create a list template out of the publishing style library and save the content with the template. 

Since the publishing site does not have a "Save document library as template" link, you’ll have to create one on your own.  Navigate to the library settings on your Shared Documents library and select the "Save document library as template" link.  You’ll notice that this is using the _layouts/savetmpl.aspx page and it is passing the List GUID as a parameter  (/_layouts/savetmpl.aspx?List=%7B1C534D30%2D9F2F%2D41A5%2DAC98%2D51CD244F532D%7D).

image

Navigate to the publishing site’s Style Library settings page (_layouts/listedit.aspx).  Now simply change the listedit.aspx to savetmpl.aspx and press enter.  Fill out the form being sure to "Include Content" and save it.

image

You should get a successful save.  Now navigate to the list template gallery.

image

Right-click and save the list template (STP) on your computer. 

image

Now all you need do is navigate to your site template gallery on your collaboration site and upload the STP file.  Then you can delete the existing Style Library and create a new list called Style Library from the template. 

image

You should now feel the love the the CQWP in your collaboration site.

image

Further investigation shows that the CQWP needs these three style sheets in order to function correctly:  ContentQueryMain, Header and ItemStyle.  Removing any of these from the Style Library will cause the CQWP to throw an error.  So, you could probably just export these styles and import them into your collaboration site’s Style Library and accomplish the same thing.

image

19
May
10

Render Failed on SharePoint List Views

Today I helped a client solve one of the many mysteries around the infamous "Render Failed" that so many people seem to get at some point in time on MOSS 2007.  In this situation, the error started appearing on several list views and nothing had been changed for several weeks prior.

After some trial and error, I found the problem was tied to several site columns that were being displayed in the views.  The site columns were lookup columns and were used many places throughout the site hierarchy.  Of course, this happened on the same day that my son and daughter-in-law were having their first child (and our first grandchild), so I found myself troubleshooting from the waiting room at Medical City in Dallas.  I know this doesn’t have anything to do with the problem, but my son’s a new father and I’m a new grandfather…so sue me!  I’ve got a captive audience and I’m a proud grandpa.  :)

CasonPose

Cason Noble Wright 2010-05-19

Anyway, it was really weird that nothing had been changed and this started and was fairly widespread.  After monkeying with filters, view styles, sorting, grouping to see if any of those things changed the outcome, I observed that, as I removed columns from the display, the views began to work.  That’s how I determined that the problem was tied to the site columns that were of the type "lookup."

To make things worse, later during the day the SharePoint site completely quit.  Now I suspected something was amiss on one of the servers.

This client has a simple two-server setup, so I VPN’d in to each server.  When I got on the SQL Server, I found that AUTOMATIC UPDATES was on and the machine had been updated and was awaiting a reboot.  Ah ha!  Finally a potential root cause. 

I quickly contacted the client and told them to reboot the SQL Server and the problem was solved.  And, TURN OFF AUTOMATIC UPDATES ON A PRODUCTION MACHINE!!!

Now, back to the grandbaby…

Reference Links:

Render Failed on a List View

KB950901

SharePoint Issues

KB925425

11
May
10

Multi-valued (Multivalue) Fields (Managed Properties) in Search not Returning All Values

Update 20100908:  Leslee completed this in the production environment and it worked the first time.  I’m calling it a wrap!

Update 20100826:  We just did this in our staging environment and got it to work the first time through!

Update 20100802:  I’ve rewritten this post a couple of times, adding more detail as we find it.  We think we might be on to finding "the recipe," but we’ll only know for sure when we repeat the process in the staging and production environments and get repeatable results.  This post is "in-work."

Oh man, this has been driving us CRAZY (just ask Leslee)!  We have a multi-valued column in SharePoint (Subject) and we couldn’t get all the values to show up in the search results.  All we could get is the last value.  See this post: Always returning last value.

We had different results before we upgraded to SP2.  In SP1, we were getting some weird results with some of the values being returned as ;#Value;# or some such nonsense.  We hope we don’t see that again.

Currently, we are on SharePoint 2007 SP2 with the February 2010  June 2010 cumulative update with the infrastructure updates installed.

There were a few hints from Ontolica (Surfray) from this post.

From this post by Michael Schau, we started to deduce a method to fix the problem.  Here’s what we came up with.

Overview:

  • Remove the mapping between your managed property and crawled property.
  • De-select the "Include values for the property in the search index" field on your crawled property.
  • Edit your crawled property category and select the checkbox to “delete all unmapped crawled properties.”
  • Reset all crawled content.
  • Perform a full crawl.
  • Add your mapping back between your managed and crawled property.
  • Change the HasMultipleValues column to True for your managed property in the MSSManagedProperties table in the Shared Services database (void your warranty).
  • Change the VariantType column to 4127 for your crawled property in the MSSCrawledProperties table in the Shared Services database (void your warranty again).
  • Perform another full crawl.
  • Perform an incremental crawl (not sure if this is really necessary, but it’s pretty quick).
  • Perform an IISRESET on all SharePoint boxes.

Let’s start with the ugly part first.  You’re not going to like this but, if MS doesn’t have software that correctly updates the database, then we’ll do it manually.  After all, it’s just a database!

Find your SSP database in SQL Server Management Studio.

image

Find the MSSManagedProperties table and open it for editing.  Locate your managed property using its FriendlyName and change the HasMultipleValues column to "True" (or 1).

image

image

Now find the MSSCrawledProperties table and open it for editing.  Locate your crawled property using its PropertyName and change the VariantType column to 4127.  We found when you change the VariantType to 4127 the Multi-valued field changes to "Yes."  All of the multi-valued fields we could find had this variant type.

image

image

The variant type for a text field is 31 (0000000011111).  The variant type that shows up on a multi-valued text field is 4127 (1000000011111).  Could it be that the leading bit identifies the field as multi-valued?  Here’s an incomplete table for the crawled properties in the SharePoint category.

Variant Type Multi-valued Decimal Binary
Text False 31 0000000011111
Text True 4127 1000000011111
Binary False    
Binary True    
Integer False 20 0000000000010
Integer True    
Yes/No False 11 0000000001011
Yes/No True    
Decimal False 5 0000000000101
Decimal True    
Date/Time False 64 0000001000000
Date/Time True    

image

You are done modifying the database.  Great job!  You’ve now voided your warranty.

Now we’re going back to Central Administration in the SSP where your search is located.

Remove the mapping for the crawled property from the crawled metadata store.  You can get there from the Metadata Properties page by clicking on Crawled Properties.

image

Find and edit your crawled property.  Remove the mapping and de-select the "Include values for the property in the search index" field.

image

Find your crawled property group (SharePoint in our case) and drill into it.

image

Click on Edit Category .

image

Select the checkbox to delete all unmapped crawled properties and click OK.

image

Reset all crawled content and perform a full crawl.  I hope you don’t have too much data!  Perhaps you should have thought to limit it before you started!

image

After the full crawl has completed, you need to add your property back.  It should be in the crawled properties.  You need to map it back to your managed property.  After you have it added back, perform ANOTHER full crawl, after which, you should see the property is correctly classified as multi-valued.

image

What does this get you?  Now, if you look at the raw XML search results for your managed property, you should see the multiple values returned.  In this example, we’re looking at a managed property called owssubject.

image

And, if you apply your XSLT, you should get something that’s nice looking, like this!

image

Search terms:

Multivalue fields in SharePoint search not returning all values

Multivalued fields in SharePoint search returning single value

Multivalued fields SharePoint search not working – broken

Can’t get multivalue field to return more than one result in Sharepoint search

01
Apr
10

Changing the Content Type on a SharePoint Page Layout

Here’s the situation.  You created a content type and a page layout based on that content type and then discover that you need to redefine content types. In fact, you find that you should have created a parent content type and had other content types inherit from it.  After reworking your content types and site columns you now want to change your page layout so it references the correct content type.  You can do this by visiting the Master Page Gallery in SharePoint and changing the Content Type Name on the properties page.  If you were looking for a place to do this in SharePoint Designer, I haven’t found it.

Now, when you go back to edit the page layout in SharePoint Designer, you won’t get all those nasty errors informing you that it can’t find the Page and Content fields because it can’t find the content type.

 

image

15
Feb
10

Changing the Group on a Site Column Causes Hidden Fields to Display on a Content Type

I ran into this problem recently.  I had a number of site columns that were hidden on multiple content types and I "recategorized" the site columns into a single group (simply for administrative purposes).  As a result, all my forms began displaying the hidden fields (instead of keeping them hidden).

Here’s the scenario.  I have a content type, Generic Task, that is used as the parent of many other content types.  You can see from my first screen shot that I have a content type (called Badge Access Task) that is inheriting from Generic Task.  When a user interacts with the task list Edit form I only want them to see and update the two fields at the bottom (Badge Access and Badge Access Comments).  All the other fields are hidden and are only used by workflows.  If you haven’t done this before, you can still see the hidden fields in a view, but the New, Display and Edit forms don’t show the hidden fields.

clip_image002[11]

 

Here’s the problem I was having.  After I changed the group that my Generic Task site columns were in, they all started showing up on my Edit forms.

 

clip_image002[13]

 

To correct this problem, I simply went into each site column on each content type and clicked OK.  I didn’t make any changes to any of the information on the form.

 

clip_image002[15]

 

This appears to have had the desired effect.  After performing this procedure on each site column on the content types, all of my fields were again properly hidden.

 

clip_image002

 

As an FYI, this is on an MOSS 2007 farm with SP2 (and patches) applied.

10
Jan
10

Fixing SharePoint Breadcrumbs to Remove the Pages Node and Display the Page Title Instead of the ASPX Page Name

If you are customizing a master page and you find that the breadcrumb is being displayed with the Pages node and the name of the ASPX page like this

image

and you’d like the breadcrumb to be displayed in the standard publishing fashion without the Pages library node and with the page title instead

image

change the SiteMapProvider from SPContentMapProvider to CurrentNavSiteMapProviderNoEncode on the asp:SiteMapPath tag.

 

<asp:SiteMapPath SiteMapProvider="CurrentNavSiteMapProviderNoEncode" id="ContentMap" SkipLinkText="" runat="server" PathSeparator=" :: "/>

11
Sep
09

Cascading Drop-downs in a SharePoint Custom Task Form

I’m documenting my journey into a land where I’m not completely comfortable…javascript.  While I have been a software developer and DBA at times during my career, it’s been a while since I’ve had to do much with javascript.  So, like one of my students recently said, “I code in Google.NET.” 

A client had a requirement for cascading drop-down menus and found a great post by Marc Anderson about cascading drop-downs on a SharePoint form.  In fact, Marc’s turned it into a three-part series, culminating in a jQuery library for SharePoint Web Services.  I tried helping him implement part one and part two without much success.  There seems to be a real problem with the javascript function getElementsByTagName in IE and it not returning a correct array of objects when it’s called…e.g. getElementsByTagName(“td”).  So, after spending five or six hours not getting anywhere, I decided to try the jQuery library version. 

First, you need to get a copy of jQuery.  You can do that here.  This needs to be referenced in your code.  A simple way to do this is to create a document library in SharePoint and upload your javascript files.  Of course, the library must be able to be read by anyone using the code.  You can see the library I set up and jquery-1.3.2.min.js that has been uploaded (along with other things).

image

Then you need to get a copy of the SPServices jQuery library and upload it.  It is out on CodePlex here

In the code window in SPD, you can reference the libraries thusly:

<script language="javascript" type="text/javascript" src="http://portal.awbikes.local/SiteDirectory/wf/JS/jquery-1.3.2.min.js"></script>

<script language="javascript" type="text/javascript" src="http://portal.awbikes.local/SiteDirectory/wf/JS/jquery.SPServices-0.2.8.js"></script>

Important Note

It is important to note that I’ve found that the order in which the libraries are referenced is important!  So important that, if they are reversed, you’ll likely get an “‘SPServices’ is null or not an object” error.  This was plaguing me for several hours.

Here’s a picture.  Click on it to make it bigger.

image

Then you have to “call” the javascript function.  It was recommended to me to use the document.ready syntax. 

<script language="javascript" type="text/javascript">
$(document).ready(function() {
        $().SPServices.SPCascadeDropdowns({
        relationshipWebURL: "
http://portal.awbikes.local/SiteDirectory/wf",
        relationshipList: "SubServiceTypes",
        relationshipListParentColumn: "Title",
        relationshipListChildColumn: "SubServiceCategory",
        parentColumn: "AM Sub Service",
        childColumn: "Sub Service Category"
        });
    });
</script>

Again, a picture of the code.

image

relationshipWebURL

The relationshipWebURL can be left blank as long as the relationshipList is in your site.  Otherwise, specify the URL of the site that has the relationship list.

relationshipList

The relationship list is a simple list with two columns that indicates what the allowable values are (column2) for each value in column1.  So, if you a relationship of Country/State, you’d have to list a country many times (50 for the U.S.) and enter a unique state on each line.  If you had two countries (U.S. and Canada), each time a country is selected in the primary drop-down list, the secondary drop-down would populate with the list of states (or provinces) valid for the selected country. 

relationshipListParentColumn

The relationshipListParentColumn is the internal name of the primary or first column in the relationship list.  The internal name can vary greatly from the displayed name.  Usually, if you put spaces in a column name, you’ll find the spaces are replaced by _X0020_, but you also have to be careful about other liberties that SharePoint takes when creating internal field names.  To view the internal field name, go to the list settings and click on the column name.  You can look at the end of the URL and see the internal field name where it says &Field=XXXX.  Here’s an example.

image

You’ll also see the underscores and other “unsafe” characters have been URL-encoded.  %5F is the encoded version of the underscore (_) character.  So, AM Sub Service becomes AM_x0020_Sub_x0020_Service.

relationshipListChildColumn

The relationshipListChildColumn is the column that will change and be filtered based on the selection of the parent column.  Similar to the parent column, you need to specify the internal field name for this column.

parentColumn

The parentColumn is the display name of the parent drop-down list on the form.  You can find this in the form in code view in SPD.  This corresponds to the title of the control.  If you use the IE developer toolbar (for IE7 or prior versions), or use the built-in developer tools in IE8 (F12), you can find the properties of the control, including the title.  Here’s IE7 with the “Find by Click” function enabled in the developer toolbar.

image

You can also look in the code view in SPD and find the <datafields> tag.  Here you’ll see a listing of all the data fields’ internal and friendly names.  Here you can see AM_x0020_Sub_x0020_Service_x0020 and AM Sub Service 1.  I’m not really sure where the ending “1” went on the internal name…must be a SharePoint weirdness.

image

childColumn

The childColumn is similar to the parentColumn except it’s the one that get populated based on the selection of the parent column.  You need to specify its friendly name or title.

image

Again, looking at the <datafields> tag you can see Sub_x0020_Service_x0020_Category and Sub Service Category as the internal and friendly field names.

image

My Problem

My problem was I was receiving a “‘SPServices’ is null or not an object” error whenever I tried to use the code.  Here’s what the debugger was showing from within the executing code.

clip_image001

It turns out that the problem was resolved by changing the order of the script references as stated previously in this post.

Application

Now, on to the fun stuff.  Here we are, in a SPD workflow using the “Collect Data From a User” action.  This action creates a custom task form that is used to “collect” (imagine that) data from a user when the workflow creates a task and pauses for task completion.  We want to use the cascading fields within the custom task form.

image

Within the workflow I’ve opened up the custom task form that was created by the action in the workflow. 

image

It is within the PlaceHolderMain area I’ve strategically placed the code that will control the drop-down lists.

image

Executing the Edit task function which uses the custom task form, you can see that I have success!

image

image

In the application of cascading drop-down menus on a custom task form I still have one problem to resolve.  When I complete the task, an unexpected error occurs.  In thinking about this, I’m wondering if this might be caused by the extra values added by the javascript not being accounted for by the form.  I still need to check this out and determine the source of this error.

image

26
Aug
09

Indexed Columns in SharePoint 2007

Here is a great in-depth article on what happens when you define an index on a SharePoint column.  You get to the Indexed Columns functionality by going into the settings of a list or library and looking at the links at the bottom of your column list.

Indexed Columns

It’s very simple to check a box next to a column you want to index, but be aware, you are NOT creating a true SQL Server index.  What you are doing is putting the values of the column in a name/value pair table and SharePoint is using these entries in a join to the UserData table in an attempt to increase performance when you have thousands or millions of items in a list or library.

My experience has shown that, in our situation where we have libraries with up to 40,000 items and custom SharePoint applications querying those libraries, we are not seeing any significant performance increase.  Your mileage may vary.




Asif Rehmani’s SharePoint Videos

SharePoint-Videos

Click to access a wealth of SharePoint videos

SharePoint Rx

SharePoint Rx Home

Categories

Posts by Date

May 2012
M T W T F S S
« Mar    
 123456
78910111213
14151617181920
21222324252627
28293031  
Support Wikipedia

Follow

Get every new post delivered to your Inbox.