Friday, June 13, 2008

The file manifest.xml does not exist in the solution package !!

While doing solution deployment was hit upon with an error message :
"The file manifest.xml does not exist in the solution package".

After several attempts to figure out what was going wrong, noticed that the package size was getting limited to 1400 KB irrespective of wether I removed or added several files.

Could overcome this by adding following lines (thanks to this ref) at the start of cab.ddf file.

.Set CabinetFileCountThreshold=0
.Set FolderFileCountThreshold=0
.Set FolderSizeThreshold=0
.Set MaxCabinetSize=0
.Set MaxDiskFileCount=0
.Set MaxDiskSize=0

This removes the file size limitations.

Special Characters in filename in .wsp file

Was bitten by a wierd issue while working on Solution deployment recently :

Error : Failed to extract the cab file in the solution

Some rounds of checks helped to locate the cause. One of the file packaged had "@" in the filename.

Hence be sure not to use any special characters in filename while getting the solution package ready.

Default RowLimit in SPQuery

Fumbled upon a strange behavior when using "SPQuery". Used SPQuery in one of the places and found that it is not returning all the results from the List queried !!!!

There was no way of debugging to locate the culprit until some SDK documentation came to rescue saying that the default resultset rowlimit for SPQuery is 100.

So make it a point to explicitly set it to some higher number :
query.RowLimit = 500;

When using "Lists" webService available in MOSS 2007, GetListItems has a parameter rowlimit which would allow to set this rowlimit.

Also when using SPQuery it bydefault would search only the current folder in the List. WSS v3.0 allows to search all subfolders in the same query using :
query.ViewAttributes = "Scope=\"Recursive\"";

This is especially important when querying Discussion Board list as it uses Folder hierarchy to store all the replies for a particular topic.

Getting an "There has been an error while processing the form." error while submitting a browser based InfoPath form :

While working on a Browser based InfoPath error was struck by an error message while submitting the form.

The intresting part was that the form was working perfectly when run from InfoPath client.

Something in the form was preventing it from getting submitted.Could not locate the culprit even after thorough recheck of logic.

Thanks to
this thread for helping me to find that the cause was a Secondary data connection
that was not getting used anywhere in the main datasource.

Error While trying to access Sharepoint List in subsite using Lists Webservice ?

I wanted to access the data from SharePoint List present on remote server in an utility. As the site was pesent on remote server, I used Lists WebService to access the data.

I added the WebReference as : http://mainsite/subsite/_vti_bin/Lists.asmx
and tried to run the code only to be hit with a Soap Exception.

Following are the error details I got :
System.Web.Services.Protocols.SoapException was unhandled by user code
Message="Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at ProdLists.Lists.GetListItems(String listName, String viewName, XmlNode query, XmlNode viewFields, String rowLimit, XmlNode queryOptions, String webID) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\utility\f0b09a93\a4ef1a67\App_WebReferences.3-c5ghn5.2.cs:line 496
at _Default.Page_Load(Object sender, EventArgs e) in d:\Projects\Utility\Default.aspx.cs:line 45
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Was unable to find the reason for this bahavior, however figured out that eventhough the reference was added to the WebService under subsite, it bydeault points to the Lists under mainsite or the top level site.

To tackle this I had to set the URL property expicitly at runtime.

Following are the lines you will have to add to be able to access the lists under any subsite :

ProdLists.Lists prodService = new ProdLists.Lists();
prodService.UseDefaultCredentials = true;
prodService.Url = "http://mainsite/subsite/_vti_bin/Lists.asmx";

Working with data from different SharePoint Fields

Many times we spend lots of time in small tasks like understanding the format in which SharePoint data is stored internally when using object model to retrieve/store data in SharePoint lists. So thought of getting all in one place.

Many of the field types like text, Number etc are straightforward to get/set.
A cleaner and professional way of working with the data from Fields would be to make use of Field Value Classes provided.

Following Field Value classes are available:

1) To retrieve value from URL field :

SPListItem linkItem = SPContext.Current.Web.Lists["Links"].Items[0];
SPFieldUrlValue val = new SPFieldUrlValue(linkItem[SPBuiltInFieldId.URL].ToString());
string linkURL = val.Url;
string linkText = val.Description;

2) To Save value in URL field :

string linkURL = "";
string linkText = "SampleWebsite";
SPFieldUrlValue val = new SPFieldUrlValue();
val.Description = linkText;
val.Url = linkURL;
SPListItem linkItem = SPContext.Current.Web.Lists["Links"].Items.Add();
linkItem[SPBuiltInFieldId.URL] = val;

Following are some more references on this :