WSS & MOSS – workflowProperties.Item.Update causes new versions

29 06 2009

I haven’t really worked with workflow in a document library with versioning turned on yet…until now.

What we found is that each time some metadata of the document was changed using workflowProperties.Item.Update, a new version of the of the file was created!

You could argue that  this is OK and for the majority of implementations this would probably be fine however we needed to find a way around it:

If you do not want to re-version the document when a workflow changes the metadata then you can use the workflowProperties.Item.SystemUpdate method, see the details here –

http://msdn.microsoft.com/en-us/library/ms461526.aspx

The SystemUpdate method writes the data directly to the database and also accepts a boolean flag defining whether or not to increment the version number, perfect!

Hope this helps! :-)





SharePoint 2010 Screenshots Leaked

23 06 2009

Hi all,

I thought I’d post up a link to an interesting blog post I found, Lee Richardson has posted some leaked/exposed details of SharePoint 2010 – these include a couple of screenshots and the details that the product will include inline list AJAX editing!

I’m sure you are all like me excited about the new product so have a look at his blog post to see more –

http://rapidapplicationdevelopment.blogspot.com/2009/05/secrets-of-sharepoint-2010-exposed-at.html

Thanks Lee! :-)





Logging to the SharePoint ULS logs programmatically

18 06 2009

When writing SharePoint applications error messages should be handled appropriately, as well as displaying a message to the user it may be useful to log this message to the SharePoint 12 hive error logs. The SharePoint error logs sit in the following location of the server – 12 Hive\LOGS.

To write a message to the log directly from custom code you can use the Microsoft.Office.Server.Diagnostics.PortalLog class, simply reference the Microsoft.Office.Server.dll and use the following method:

PortalLog.LogString(yourerrormessage)

The LogString method accepts a string so just pass in your exception message and your good to go. Additionally the ‘DebugWriteString()’ method works the same way as the above but allows you to specify the level of the item that you are logging (Critical, Error, Information or Verbose).

Hope this helps someone! :-)





‘Fear’ of the SharePoint Content Databases

12 06 2009

I have recently read a few interesting comments from people on the web regarding SharePoint content databases, it seems almost fear the prospect of delving in to the content databases.

I appreciate that modifying data in the content databases could mean that your warranty/support contract is no longer valid but for reading data I personally find it very helpful. I have created a number of SQL Reporting Services reports that read their data straight from the content databases and often this is a lot quicker than point the report straight at the SharePoint site.

I would be interested to hear peoples comments on this, it almost seems that because SharePoint is designed with a rich front end for the users that the backend databases should not be touched. One thing that is frustrating though is the way that SharePoint stores the data in the AllUserData table, each column in SharePoint is represented by a seemingly random name in the table – e.g. a field called ‘User Name’ could be ‘varchar1’ in the table. The number would increase for each column of that type.

Let me know what you all think…





Issues when installing Timer Job from Feature Receiver

4 06 2009

I am currently working on a custom timer job to provide some basic archiving functionality for one of our SharePoint sites. Whilst doing this I have come across a few problems when you use a feature receiver to install the Timer Job for you, Molnar Tibor has a useful blog post explaining the problems and solutions -

http://geekswithblogs.net/MTex/archive/2008/07/27/124065.aspx

I will explain them here too for clarity:

1.When you active the feature you may receive the following error:

System.Data.SqlClient.SqlException: The EXECUTE permission was denied on the object ‘proc_putObject’, database ‘SharePoint_Config’, schema ‘dbo”

The means that the web app’s application pool account does not have the correct access to the SharePoint Config database. You will need to set the correct permissions in SQL Management Studio – security admin permissions should be ok.

2.After you have completed the above, the code for deleting the timer job will throw an exception –

Access to the path ‘C:\Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config\360c4621-fccb-4c2a-9182-b3c75ae80cf3\cache.ini’

In order to solve this you need to give the WSS_WPG account full control on the folder that contains the cache.ini file, in this case ‘360c4621-fccb-4c2a-9182-b3c75ae80cf3’.

Hope this helps! :-)





WSS – Rich Text column in Document Library

28 05 2009

I came across this issue the other day, you cannot add a rich text column to a document library, this was frustrating as I wanted to use the column to hold multiple html hyperlinks.

After doing some research I found this post on SharePoint Blogs –

http://www.sharepointblogs.com/forums/t/16166.aspx

It is possible to use a rich text column in a doc library but it must be done using a content type, I’ve written some instructions below on to get a document library setup with a rich text column:

  1. Configure ‘Advanced Settings’ for the document library and enable the management of content types.
  2. Create a new Site Column as multiline rich text.
  3. Create a new Content Type and add the column created in step 2.
  4. Add the Content Type to the document library using the ‘Add from existing site content types’ link.
  5. Save the document library as a template and delete the document library.
  6. Create the document library again using the template from step 5.
  7. Success! You should now be able to use a rich text column within a document library.

Hope this helps some people! :-)





Bug in MOSS Service Pack 2

26 05 2009

For those of you who are not yet aware, Microsoft have discovered a bug in Service Pack 2 for MOSS. Once service pack 2 is installed, it resets the license of SharePoint server to the 180 day trial license. This means that if not remedied, the license could expire and access to the environment would be blocked.

The official blog post by the MOSS team is here –

http://blogs.msdn.com/sharepoint/archive/2009/05/21/attention-important-information-on-service-pack-2.aspx

The problem can be fixed by re-entering the license key (in the ‘Convert License Type’ page of Central Administration) or waiting for a hotfix which should be posted on the Microsoft support site sometime soon.

Hope this helps!





SharePoint Event Handlers – Getting item properties in the ItemAdded event

15 05 2009

As some of you may know, it is a real pain to try and get hold of an item’s properties in the ItemAdding or ItemAdded event, there are various blog posts describing the problems and possible solutions.

The one blog post that stands out for me is this one by Randy Williams –

http://www.synergyonline.com/blog/blog-moss/Lists/Posts/Post.aspx?ID=25

It seems if you are using a List rather than a document library then you can use the AfterProperties[“Fieldname”] to get the value in both the ItemAdded/ItemAdding events.

With a document library however, it seems to be a different story – both the ListItem.Properties and AfterProperties collections return no value when queried with the fieldname e.g. AfterProperties[“My Field Name”]. I have even tried using the internal field name – “My_x0020_Field_x0020_Name” but this also returns a null reference exception.

Well today, I have had a bit of a breakthrough – rather than reading the value directly from the properties.ListItem or properties.AfterProperties you need to first create a new SPListItem and then read the value from that. See my previous and now working code below:

Previous (Non-Working) Code:

(if properties.ListItem[“My Field”] != null)

{

string mystring = properties.ListItem[“My Field”].ToString();

}

The above code would always return a null reference exception when it first checked for the properties.ListItem[“My Field”] not being null.

Working Code:

SPListItem item = properties.ListItem;

(if item[“My Field”] != null)

{

string mystring = item[“My Field”].ToString();

}

I can only imagine that creating a new SPListItem and querying that retrieves all the values after the item has been added to the database – I am not really sure! All I can say is that it works well so I am going to use this method on all future event handlers.

Hope this helps someone! :-)





SharePoint Event ID 3351 – Login failed for user ‘NT Authority/Anonymous Logon’

13 05 2009

I have noticed the above error keeps popping up in the Application event log of our SharePoint server so I decided to track down the problem. Initially I thought it might be application pool based but it turns out it is the ‘Microsoft SharePoint Services VSS Writer’ service that is causing the problem.

I found the solution over at the TechNet forums –

http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/7efeefce-129e-4a03-9ff7-900d6168952b

It seems the solution is to change the identity for the service to run under the SharePoint Active Directory  farm account rather ‘local system’ which is the default.

After you change the identity, restart the service and the error should no longer keep bothering you.

Hope this helps someone! :-)





Windows 7 RC

7 05 2009

windows-7-logo Just thought id write a quick post about the recently released Windows 7 Release Candidate (Build 7100). I am now running this as my main OS and must say I am pretty impressed. Microsoft seem to have channeled all their effort into fixing Vista’s flaws and providing a stable base similar to Windows XP.

Boot up/load time of the OS is incredible, vista would take a good few minutes to load all my applications and be booted up ready for use. In contrast Windows 7 can go from login screen to fully loaded in under 30 seconds. I have been using 7 for about a week now and have not managed to make it crash or blue screen once so it seems strong in the reliability stakes.

The interface of 7 is very similar to vista except for the modification of the task bar to display the icons of the currently loaded apps rather than the icon and the text. This means you can fit a lot more onto the taskbar, its a bit odd at first but fine when you get used to it.

A new addition in windows 7 is ‘Virtual XP Mode’, this is a downloadable add-on from http://www.microsoft.com/windows/virtual-pc/ that is basically a glorified virtual machine. It allows you to run any application inside of a windows XP environment, great for those who don’t want to move to 7 because of compatibility issues.

All in all I am very impressed and certainly won’t be going back to vista! The RC is currently available for download from the MS site:

http://www.microsoft.com/windows/windows-7/download.aspx

Once registered you can also download a serial key. The RC build expires in 2010, plenty of time as 7 should be released by then. :-)