Posted: December 29th, 2009 | Author: davecavins | Filed under: General SharePoint | Tags: Document Library, SharePoint, SharePoint Designer, Workflow | 2 Comments »
On a recent project I had to migrate a large number of documents from a legacy system into SharePoint. In the old system users to choose what text would be displayed as the link. In most cases users chose not to use the actual file name as the link text.
The Problem
In SharePoint users don’t have as much control of what gets displayed. There is a ‘Title’ field but it can’t be used in a calculated column and on the standard document library it is not a required field.
Technically the file name could be used but this could lead to very long file names with spaces and special characters that could cause problems by forcing the page to scroll as well as creating some REALLY long URLs.
Depending on the type of document the actual file name may be irrelevant to the use while the title would be more helpful. For instance a in document library of meeting minutes the file names could just be the date of the meeting for example (12_03_2009.docx). The document title could be used to contain not only the date but other relevant information about the meeting like who attended or important issues that were discussed. Additionally the title field can support special characters and spaces that could be a problem in file names.
Read the rest of this entry »
Posted: December 4th, 2009 | Author: davecavins | Filed under: General SharePoint | Tags: jQuery, pre-populate, SharePoint | No Comments »
So I was working with a friend on a custom SharePoint list. When users create a new item certain fields needed to automatically populate with information from their profile. We ran into issues when trying to populate the people picker.
Scripts like SPFF can be used to accomplish this but we needed something else because we wanted to read in the current user’s information from the SharePoint web service. Additionally we wanted to avoid passing information using the query string because users would be able to access the form through multiple links.

People Picker
So to prefill the form with some information we used a simple jQuery script in a Content Editor Web Part on the NewItem.aspx page. Initially we tried to target the input by using its title. This did not work so I looked at the code of the page using FireBug. It turns out that the field is actually a hidden textarea and what you see on the screen is actually just a div with a class of ms-inputuserfield. Here is part of the code we used to populate the people picker.
<script type="text/javascript">
var user = "dcavins"
$(document).ready(function() {
$('div.ms-inputuserfield').text(user);
});
</script>
This script can used along with the SP web services to prepopulate the people picker and other fields of a list. This is useful if you have a contacts list where you want people to be able to add themselves or a task list where users are supposed to assign items to themselves. Prepopulating fields makes it easier for the user saving them time.
The Rich Text Field is similar to the people picker in that it also hides the actual textarea and uses a div instead. In a later post I will explain how to use the web service to prepopulate list fields with information from the current users profile.
Posted: November 10th, 2009 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: jQuery, SharePoint, slideshow, web services, webparts | 11 Comments »
This is a very simple image slide show script that uses jQuery, SharePoint webservices and the default images library to show images with captions. All the content is pulled from default fields in the images library but feel free to add more fields and customize the code to fit your needs.

Slide show with captions
Read the rest of this entry »
Posted: November 2nd, 2009 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: forms, jQuery, SharePoint, textarea | 5 Comments »
So one of the things that I have had end users complain to me about is the size of the text boxes on the new and edit forms of lists like the contacts list and announcement list. On a recent non-SharePoint project I used a jQuery plugin to create a resizable text area so I tried to implement it in SharePoint. Here is what happened.
I downloaded the Textarea Resize JavaScript jQuery plugin, saved in a SharePoint library along with the latest version of jQuery.
Selecting the Element
In order for the jQuery code to work it has to know which elements on the page you want to work with.
Here is the code SharePoint renders for a text box:
<textarea name="ctl00$m$g_3fa2cde8_0ea8_4421_814f_6a6d292fbe54$ctl00
$ctl04$ctl0ctl00$TextField"
rows="15"
cols="20" id="ctl00_m_g_3fa2cde8_0ea8_4421_ctl00_TextField" title="Body"
class="ms-long" dir="none"></textarea>
There are two problems:
- ASP.NET creates very long and hard to use IDs
- The class ms-long culd apply to other elements on the page that I dont want to use the effect on.
Read the rest of this entry »
Posted: October 28th, 2009 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: jQuery, search, SharePoint, suggestions | No Comments »
In Part 1 of this post we used a simple javascript to display suggestions on a custom search box. After I wrote that post I was thinking it would make more sense to read the suggestions from a list instead of a JavaScript file. This post will explain how to setup the list and edit the JavaScript to read the suggestions from a list. The idea is that an administrator could manage the list and help guide users toward specific information instead of getting numerous un-related results like in those commercials for bing.
Assuming you already have the search box setup as described in Part one of this post all you will need to do is change the javascript and add some code to the page.
Setup
- Do everything from the first post
- Add a link to jQuery somewhere on the page.
- Create a custom list called ‘Suggestions’. It just needs to have the default title field. Create at least one item in the list and in the title enter several comma separated words.
- Add the code below to the page.
<script type="text/javascript” src=“http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js”></script>
<script type="text/javascript">
function GetItemsFromSP() {
var soapEnv =
“<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Suggestions</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>”;
$.ajax({
url: “_vti_bin/lists.asmx”,
type: “POST”,
dataType: “xml”,
data: soapEnv,
complete: processResult,
contentType: “text/xml; charset=\”utf-8\”“,
async: false
});
}
function processResult(xData, status) {
$(xData.responseXML).find(“z\\:row”).each(function() {
$(“#data”).append(“” + $(this).attr(“ows_Title”) + “,”);
});
}
</script>
<script type=“text/javascript” src=“Resources/searchfield.js”></script>
<div style=“display:none; visibility:hidden” id=“data”></div>
The code above get the items from the Suggestions list, seperates them with commas and puts them in a hidden div with an ID of data. Now we just need to edit the searchfield script to read in the information from our hidden div. To do this edit searchfield.js line 26 to call the GetItemsFromSP function and set the suggestionText variable to be equal to the contents of our hidden div. Here is the code.
/**/*/*/*/**/
GetItemsFromSP();
var suggestionText = $(“#data”).html();
Test the page and make sure it works by typing the first few letters of one of the words in you list item.
Conclusion
This is very similar to Jan Tielens’ SharePoint Search-as-You-Type with jQuery solution but I wanted the search box to still be usable even if there are no suggestions. In Jan’s solution the ‘search box’ does not actually do anything when the magnifying glass is clicked. There are likely better ways to do this and if you know of one please post a comment.
Posted: October 27th, 2009 | Author: davecavins | Filed under: General SharePoint | Tags: Chip Dizard, Google Wave, SharePoint 2010 | No Comments »
I was reading this article last week and it reminded me of a conversation I had with a developer friend of mine back when SharePoint 2007 came out. I was telling him that because of the ability to integrate so closely with Office SharePoint would end up dominating the market for collaboration tools.
SharePoint is not the only collaboration tool available and some would say it is not the best tool either. Google Wave, BaseCamp, Salesforce.com and others offer similar capabilities in some areas. As Chip Dizard of Absolute Presence points out Wave does not work well with IE but does integrate nicely with Google’s other online tools (Docs, Calendar, etc.). For open source fans and Microsoft haters there are several good options but it is hard to deny the convenience of SharePoint.
Most large organizations are already using Microsoft Office products for email and word processing so the fact that SharePoint works seamlessly with these applications makes it an obvious choice when it comes time to collaborate and share information. Even SharePoint 2003 had some integration with the Office products but Microsoft has taken things even further in SharePoint 2010. With such a fully integrated solution that most users will have to use as part of their work competitors like Google will have a tough time selling to businesses and large organizations.
For smaller organizations that don’t have the resources or the need for all of SharePoint’s features may Google Wave and other tools very useful. Larger organizations who require information security, full control and data backups will find SharePoint quite capable. This article has more information on how the SharePoint team has worked to build SharePoint into its own platform
Posted: October 9th, 2009 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: blog, CSS, SharePoint, SharePoint Designer | 3 Comments »
Out of the box the comments on SharePoint blogs dont look that good.

Standard SharePoint blog comments
Here is a way to fix that problem. Just add this CSS to the page and things should start looking alot better. Read the rest of this entry »
Posted: September 28th, 2009 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: page title, SharePoint | No Comments »
When working with multiple browser windows open its hard to tell one from the other because most SharePoint pages don’t offer a useful title. So in most cases you will see something like this (I am using the dreaded IE 6 unfortunately). As you can see most SharePoint pages only show the title of the page. On the home page of some sites the site name is shown as well.

Useless Page Titles
Ideally the page title should not only tell you the title of the page you are looking at but also what site you are on. Chris Coyier of CSS-Tricks talks more about different options in this post. After some experimenting I was able to get this working in SharePoint.
Read the rest of this entry »
Posted: September 15th, 2009 | Author: davecavins | Filed under: General SharePoint | Tags: attachments, Data View Web Part, SharePoint, xsl | 4 Comments »
So on a recent project I needed to show a link to the attachment for each item in a list. A quick Google search found How to show Attachments with DataFormWebPart from Dario Martirani Paolillo’s Web Log. I was excited because it seemed to work well and was very easy to implement.
As I was about to finish up the project I was given some new requirements which meant that there would be two Data View Web Parts on the page and both would need to show the attachments link. This is when the issues started. When you have two web parts on the page using the display attachments code the second one will just show “[value of field: Attachments]” instead of the actual link. If anyone knows a good solution for this issue please post a comment.
I want to avoid using something like this jQuery solution by Paul Grenier simply because of the performance issues it will create.
Posted: July 14th, 2009 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: Data View Web Part, Endusersharepoint, Gabe Hilado, jQuery | No Comments »
A while back there was a post on EndUserSharePoint.com by Paul Grenier that described how to use jQuery and the CEWP to make a preview pane. I thought it was a very nice solution and worked better than the out of the box preview pane SharePoint uses.
Too Much Code
The only issue is the preview pane solution is that in environments with slow internet connections the preview pane will be almost as slow as if the user actually broswed to the display form for the item.
Although its done through AJAX jQuery is still having to load the whole DispForm.aspx and then only displaying the contents of a specific element. DispForm.aspx when rendered through the borwser (like most pages in SharePoint) is very code heavy with over 700 lines of code ( An Announcement List item). Reducing the amount of code jQuery has to load from the diplay form will decrease load times and make everyone happy.
Faster
Gabe Hilado and I decided to try to make it faster. The simple solution is to make your own diplay form in SharePoint Designer. First we tried creating a blank .aspx page and putting the list view webpart on it. The reduced the amount of code on the page but I wanted it to be even faster.
Read the rest of this entry »
Recent Comments