Archive | October, 2010

jQuery, SharePoint Web Services and adding thumbnail to a List

We have a SharePoint list with thumbnails attached to the list items. The request was to show a thumbnail of the image that is attached. I believe this can be done via SharePoint designer, but I thought jQuery would be easier. I added a Content Editor WebPart to the top of the page. Next I inserted the jQuery code below. This code queries the SharePoint Web Services for every item (not tested on a large list), and then loops through them. If there is an attachment, jQuery takes the ID and the path to the attachment and replace the ID column (has to the first column) for the item with the tumbnail image.

The tricks were:

  1. The soapEnv has to have “<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls>”
  2. Finding the right selector to get to the ID column:
$(" tr:has(").find("td:first").filter(function() {
			return $(this).text().toLowerCase() == ID;
			}).html("<img src='" + url[1] + "' width=150 height=100 />");

Here is the rest of the code:

$(document).ready(function() {

function querySPWebServices() {
        var soapEnv = "<soapenv:Envelope xmlns:soapenv=''> \
		<soapenv:Body> \
		<GetListItems xmlns=''> \
		<listName>Projects</listName> \
		<viewFields> \
		<ViewFields> \
		<FieldRef Name='Title' /> \
        <FieldRef Name='Body' /> \
		<FieldRef Name='ID' /> \
		<FieldRef Name='Attachments' /> \
		</ViewFields> \
		</viewFields> \
		<query> \
		<Query /> \
		</query> \
		<queryOptions> \
		<QueryOptions> \
		<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls> \
		</QueryOptions> \
		</queryOptions> \
		</GetListItems> \
		</soapenv:Body> \

        	async: false,
            url: "",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
function processResult(xData, status) {
	$(xData.responseXML).find("z\\:row").each(function() {
		if ($(this).attr("ows_Attachments") != 0) {
		var url = $(this).attr("ows_Attachments").replace(/#/g, "").split(';');
		var ID = $(this).attr("ows_ID");
		$(" tr:has(").find("td:first").filter(function() {
			return $(this).text().toLowerCase() == ID;
			}).html("<img src='" + url[1] + "' width=150 height=100 />");

Countdown Clocks and the MTA

Waiting for the subway this morning, it occurred to me that the MTA should not bother spending millions of dollars on Countdown Clocks. Instead, why not¬†invest in app development for smart phones. Since there will be wifi in the subways, why not work on getting data to people’s devices. No citywide maintenance costs on installed hardware, power , or labor.

Since there will already be an infrastructure in place to handle the pushing of the data to the clocks, why not push it to an app on my phone. Basically shifting the hardware costs of the colcks to the riders. Added benefit: info is available where ever you are, so you can time your arrival.

I am sure I am not the first to think of this, but it occurred to me this morning.

My esxupdate script

I was having problems using update manager on an esx box at a remote site. I needed to install several prerequisite patches before i could get to U5.
I went to : and found the patches I needed.

So I used lwp-download to download the files(esx does not have wget) like so:


Then I used the following simple bash script:

for i in ESX350-2009*.zip
unzip $i
mv {,_}$i
cd ${i%%.*}/
esxupdate --noreboot update
cd /back/to/location/of/patches
mv {,_}${i%%.*}/

Powered by WordPress. Designed by WooThemes