Wednesday, March 25, 2009

Assign value to a hyperlink column in SharePoint

Problem
I have a hyperlink field/column and want to assign a value to it using an EventHandler or Console Application..

Solution
item["HyperlinkColumnName"] = "http://www.google.mu/, Google Website";

i.e. site url, site name

When you view the list item, it will display "Google Website"
If you specify only the link, i.e. item["HyperlinkColumnName"] = "http://www.google.mu/"; then you'll see http://www.google.mu/ when you view the list item

Note: It is important that you leave a "space" after the "comma" i.e. specifying "http://www.google.mu,Google Website" is not good!!

Cheers
d[-_-]b

Friday, March 20, 2009

SPQuery not executing the query and returning all results

Problem Statement

I was writing some code using SPQuery and came across a problem where the query was returning me all the list items instead of only the filtered items.

SPQuery query = new SPQuery();

string qry = String.Format(“<'Query'><'Where'><'Eq'><'FieldRef Name=\”Field1\” /'><'Value Type=\”User\”'>{0}<'/Value'><'/Eq'><'/Where'><'/Query'>”, “Ranish”);
query.Query = qry;

SPListItemCollection results = MyList.GetItems(query);

Console.WriteLine(“Result Count: “ + results.Count);

Solution

Remove the <"Query">..<"/Query"> tag in the CAML string and the query will work fine. Silly mistake from my part…I copied the query directly from U2U CAML Builder that’s why!! Need to be more cautious next time

Cheers

d[-_-]b

Form was customized not working with attachment

Problem

You get an error if u have created a custom page for either the New or Edit page of a list and u are trying to attach a document to the list item using the custom page. The error is as follows: "This form was customized not working with attachment."

Solution

U need to apply hotfix 953749 to your SharePoint environment and then do some additional changes to your custom form. After that, the attachment will work fine.

Refer to the following link for detailed steps: http://support.microsoft.com/kb/953271

Note: The attachment works fine for a page which has not been customised.

Cheers d[-_-]b

Error when loading excel sheet using excel services

Problem statement
Was messing around with lists and decided to create a Report Library (Site Settings > Create > Report Library), to get an idea of what it can offer. So, i created the library and then decided to create a new Report. However, I got an error when trying to view the report (which was a .xlsx file). It was something like:
"You do not have permissions to open this file on Excel Services.Make sure that the file is in an Excel Services trusted location and that you have access to the file."

Solution

Add the Report Library a trusted file location

  1. Open the Sharepoint Central Administration Web application
  2. On the Central Administration home page, click Application Management
  3. On the Application Management page, in the Office Sharepoint Server 2007 Shared Services section, click Create or Configure this Farm’s Shared Services
  4. On the Manage this Farm’s Shared Services page, click SharedServices1 (Default)
  5. On the Shared Services home page, in the Excel Services Settings section, click Trusted file location
  6. On the Excel Services Trusted File Locations page, click Add Trusted File Location
  7. In the Address section, type the location and name of the SharePoint Office SharePoint Server 2007 document library that you want to add as a trusted file location in Excel Services. If the document library is stored in the Microsoft Windows SharePoint Services 3.0 content database, ensure that Windows SharePoint Services 3.0 is selected as the Location Type.
  8. In the External Data section, select the type of data connections that you will allow workbooks in this trusted file location to contain and click OK.

References:
http://technet2.microsoft.com/Office/en-us/library/00fc7447-6c0c-435c-840f-b1033710fe561033.mspx?mfr=true

About this SharePoint blog

Hi all

After much thought i’ve decided to post mostly programming stuffs on my blog. Reason is…i’m a software developer (Technical Specialist in my company to be more precise) and i want to build a knowledge base for myself (primarily) and for other developers who are working on the same technology as myself. I've been working on MOSS 2007 since it's release and hence i'll post mainly MOSS 2007 articles in this blog. Hope u guys find the posts useful. And yes, please feel free to post your comments. I'm also fluent with the French language...alors vous pouvez poster vos commentaires en francais si vous voulez :)

Cheers
d[-_-]b