Tuesday, June 23, 2009

GetListItems only returns 100 items

When using the SharePoint webservice lists.asmx you can create a simple CAML query to retrieve listitems. I discovered that when no RowLimit is set the result does not return more than 100 items. So if you want to retrieve more than 100 items be sure to specify the RowLimit when calling GetListItems.

The example below is in Delphi code:

GetListItems

The code above will return all items using a max limit of 5000 items. The code below will only return 100 items regardless of the “real” amount of list items specified.

GetListItems_1

Monday, June 15, 2009

Do not forget the <Query> in your Queries

When programming using the SharePoint WebServices you often want to write a CAML query to select items from a list etc.

When developing using the SharePoint API you do not need to write the surrounding <Query> tags. But when you submit a query to a webservice ex: lists.asmx the tags must be present.

Without the query tags the response will contain a soap exception.

It took me a while figuring this out as I was copying some C# code from an evenhandler to select items, into a Delphi app consuming the Lists webservice.

query

Saturday, May 9, 2009

Detect if PIA 2007 is installed on a computer

Distributing applications that uses the Redistributable Primary Interop Assemblies for the 2007 Microsoft Office System. Can be a challenge. A article on MSDN written by Wouter van Vugt and Ted Pattison Deploying a Visual Studio Tools for the Office System 3.0… really helped me along…

I am using Setup Factory by Indigo Rose to create my MSI package. During the initial setup I can define various launch conditions for my MSI. The launch conditions are defined by the results returned from searching for files, registry entries, components etc.

As described in the article mentioned above I am checking for the component identifier for the product that my deployed application is dependent on. In my case MS Outlook 2007.

Outlook Component ID

This will successfully detect if Outlook 2007 PIA is installed on the system. But when I removed Office 2007 PIA from the system (Not a reboot) The component search still returned true (The location in the GAC). So to modify the launch condition query I also added a folder search in the Installer directory.

Outlook Folder ID

So my launch condition for the MSI that is dependent on the Office 2007 PIA checks the presence of the installer files from the PIA MSI and the Component ID of the Outlook PIA to make sure that Outlook PIA is installed on the system.

Launch conditions

Wednesday, February 18, 2009

Show document icon using XSL and DDWRT


When displaying a document icon using XSL you may have tried to just map the image from the /_layouts/images folder using the file extension. This will work in most cases but it will not map PDF files etc. unless you add the images or edit the file mappings.

The ddwrt library has just this function made for you:

include a reference to the library in your xslt:

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

This is a snippet that includes the icon and sets the correct icon if the “file” is a folder:

<a href="{@FileRef}">
<xsl:choose>
<xsl:when test="@FSObjType=1"> <!-- Folder -->
<img alt="{@Title}" src="/_layouts/images/folder.gif" style="vertical-align: middle;border:none;"/>
</xsl:when>
<xsl:otherwise>
<img alt="{@Title}" src="/_layouts/images/{ddwrt:MapToIcon('', string(@File_x0020_Type))}" style="vertical-align: middle;border:none;"/>
</xsl:otherwise>
</xsl:choose>
</a>




Folders presented in xsl 

Tuesday, February 10, 2009

Error saving files in SharePoint

When uploading a file to SharePoint a message like “Unable to complete this operation. Please contact your administrator. at Microsoft.SharePoint.Library.SPRequestInternalClass.PutFile(String bstrUrl…” is presented.

The first thought that comes into mind is file size, illegal file types or rights.

But in this case the problem was 0 kb. free on the database server data disk!

So keep in mind that this message can indicate a problem with the space allocated to the Content database, and not necessarily a problem with the configuration.

The problem was solved by detaching the content database, moving it to another disk, truncating the log and attaching it again.

Note: This problem should have been avoided by monitoring disk- or database space.

Thursday, February 5, 2009

String.EndsWith and String.Empty

During a debugging session trying to find out why my a simple test to check a email address against a domain failed I discovered that String.EndsWith will return true if you try to compare a string and a empty string.

In my case I was checking list items with the format @domain.com against a valid e-mail address. But the function always returned the default choice. A “Please Choose” item with no domain configured. (A empty string)

In order to fix the problem I just added an if test to see if the string was empty and then ignored the EndsWith test.

Endswith 

This should have been a regular expression, but it works for now :-)

Monday, January 12, 2009

Get the Site ID in an event handler (SPItemEventReceiver)

While creating an event receiver for a list that is used to replicate project status I discovered that the SPItemEventProperties did not return what I expected.

I use the SiteID to recognize the list item when doing a update. The receiving list should only have one list item (status) for each reporting project site. To identify the site I was planning to use the property SiteId

SiteID

After reporting the status from two different sites I discovered that the receiving list only contained one list item. It should have contained two, one for each site.

Some more research discovered that the siteId is the ID of the root site, not the site where the event occurred.

Needing the SiteID of the site where the event occurred I tried using the OpenWeb() function instead

WebSiteID

The ID returned what I needed, and the event receiver reported successfully status for each subsite. I guess this just adds one more situation where you can get a little confused in the use of the terms site and web in SharePoint