Archive for the ‘Programming’ Category

A couple of tips for creating lookup columns as a feature

June 29, 2008

I recently used Chris O’Brien’s approach to create lookup columns as a feature, and it works great.

After some time, I was making a query to the SharePoint webservice, for some reports I was making – by the way, I’m using Enesys RS Data Extension for this job, I can recommend that product, it makes it much easier to write queries to SharePoint lists.
So I noticed that the columns made with Chris’s approach was not included in the response!…. Strange…

I was able to access the fields via the Object Model without problems. 

It took me quite some time to figure out, but eventually ended up compairing the SchemaXML to a regular lookup column, made in the SharePoint UI.
And there were some differences.

On my custom made lookup columns there was a namespace attribute.
After removing the attribute in the FeatureActivated method everything is running as it should.

 

 

Thanks to Frederic from Enesys for pointing me in the right direction!

Prepare your report date fields for Excel export

May 26, 2008

I made some rdlc reports to be shown in report viewer.
Often theese reports are exported to Excel, for further processing.

I made a typed dataset for my tables, defining the date columns as ‘xs:date’
To remove the timestamp in the report, I used FormatDateTime(Fields!OrderDate.Value, 2), and everything was fine….. Untill the users start complaining, that the date columns where not formatted as date in the exported excel sheet.

The solution is to use the ‘Format’ property of the field, here you can specify the formatting for dates.
For example =”dd/MM/yyyy”. Here you can also make an expression to handle different language options etc.
This approach preserves the date format in exorted excel sheets.

Restrict users shown in the peoplepicker in SharePoint

May 8, 2008

It is possible to restrict the search in the peoplepicker, so it only contains users that are registered on the site collection instead of the entire domain.

Stsadm.exe -o setproperty –url http://sharepoint –pn peoplepicker-onlysearchwithinsitecollection –pv yes

 

 

Stramit SharePoint Caml Viewer

May 8, 2008

If you’re developing for SharePoint, this is a must have tool – and it’s free:-)

Stramit SharePoint Caml Viewer lets you create a view via the SharePoint GUI, and then you can go behind the scenes with Stramit SharePoint Caml Viewer, and see the xml markup query.

Check it out: http://www.codeplex.com/SPCamlViewer

Reporting on SharePoint Data – Enesys RS Data Extension

May 8, 2008

If youre looking for an easy way to make Reporting Services reports on SharePoint data, RS Data Extension from the company Enesys is worth taking a look at.

I downloaded the trial, and spend about 10 minutes installing it, and it worked right away.

Very easy, and really powerfull tool…

http://www.enesyssoftware.com

SharePoint and Reporting Services integration

May 8, 2008

I’m currently working on a SharePoint project, where we have to run some Reporting Services reports on the SharePoint data as well as data from a DB2 database.

The tricky thing is that SharePoint site is public available to known users, but how to handle authentication with Reporting Services??

Well – Microsoft fixed that for you in SP2 for SQL Server 2005, where they introduced a feature called Reporting Services in SharePoint Integration Mode

I’m still in the early adoption fase, but it looks pretty promising to me – decide for your self…

http://technet.microsoft.com/en-us/library/bb326290.aspx

Improving code readability when using iDB2 .Net connector for iSeries

May 8, 2008

I have done a few apps over the last years using IBM’s .Net data connector for iSeries (i5)

When you use the DataReader, you usually end up with a lot of places where you access the content of your datareader like this: ‘dr.GetString(8)’
The problem is that after some time you can’t remember which fields actually had number 8 in the array, and you have to go to your SQL statement to find out.

I came across the method “GetOrdinal” on the DataReader object and wondered what was the purpose for that, and after a little googling, I found out, that it actually solved one of my everyday problems (a small one, but anayway;))

So here is how it works.
In the scope of ‘while(dr.Read())’, you call the method with the DB2 field name, and it returns an integer telling the index of the field in the datareader array: 

int db2CustomerNo = dr.GetOrdinal(“ODKUND”);

and then in your code, you can access the field using your assigned integer like this:

dr.GetString(db2CustomerNo)

No rocket science – just a little trick, that makes your day a little bit easier;)