SharePoint

Upgrading a solution fails

René Hézser

In a SharePoint farm with multiple servers, features have to be deployed to every server. No problem you would think. That is why we got solutions and deploy them with stsadm. SharePoint will do the rest.

But what do you do if you got an error during the deployment process?
In my case the error was:

A deployment or retraction is already under way for the solution xyz, and only one deployment or retraction at a time is supported.

SharePoint Web Controls to access remote content

René Hézser

In my post How to use the SharePoint Web Controls I talked about using the SharePoint Web Controls to show and edit data in SharePoint lists.

Today I want to post a sample how to work on a list, which is in another web. The remote list will be the “User Information List” which exists on every rootWeb.

 1: // connect to the rootweb, to read the users list

Modify blog post categories

René Hézser

If you plan to use the CKS:EBE (Enhanced Blog Edition), you might want to update the categories of your posts, because the EBE supports multiple categories for a post.

I’ve created a Windows Forms Application, which will help you with this task.

Features:

  • Update categories for blog posts
    • Select multiple categories
      • Remove categories from blog post
        • Add categories to the categories list
          • Modify the blog posts, without changing the modified date

          Requirements:

Is the current user anonymous?

René Hézser

If you want to find out if the current visitor is anonymous or logged on, you can use the context to get that information.

bool anonymous = Context.User.Identity.IsAuthenticated == false;

If you just go for SPWeb.Current.Web.CurrentUser, you will get logged on automatically to retrieve the current user.

Technorati Tags: ,

Upload documents/pictures to a discussion lists

René Hézser

You might already know my Wiki Webpart, which allows you to upload pictures and documents to a Wiki while editing it.

What is it?

With this Solution you can upload images and documents from the new/edit form into existing picture/document libraries. After the file has been uploaded, a link will be inserted into the Body.

This is either a or a tag, depending on the uploaded file.

How does it work?

Anonymous access and elevated privileges

René Hézser

Accessing a SharePoint site or web with elevated privileges can be achieved in two ways. By passing a SPUserToken or with RunWithElevatedPrivileges.

string currentWebUrl = SPContext.Current.Web.Url;
SPSite _siteElevated;

SPSecurity.RunWithElevatedPrivileges(delegate { _siteElevated = new SPSite(currentWebUrl); });

_siteElevated = new SPSite(currentWebUrl, SPContext.Current.Site.SystemAccount.UserToken);

<p>
  As anonymous visitor you will not be able to access SPContext.Current.Site.SytemAccount.UserToken. So use SPSecurity to get elevated objects if you have anonymous access enabled.
</p>
Technorati Tags:

 

SPQuery, ViewFields and empty fields

René Hézser

If you want your query to return empty columns, you have to add Nullable=’TRUE’ to the viewfields.

If you do not add the Nullable attribute, accessing the results of the query like this:

oListItemAvailable[“Field1”] will give an Exception.

I’ve made posted a comment about this on the page in the MSDN http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewfields.aspx

Cancel the activation of a SPFeature

René Hézser

If you have ever created a SPFeatureReceiver class, you might have noticed, that there is no “FeatureActivating”. So what do you do to cancel an activation of your feature?

Just throw an exception within FeatureActivated. This will cancel the activation process, and not activate the feature.

throw new SPException(“The feature could not be activated.");
Technorati Tags: ,

CKS:EBE

René Hézser

In case you do not know the Enhanced Blog Edition, you have to check it out. The upcoming version has lots of improvements. One is the possibility to use the extension on a non English SharePoint blog site.

I am working on the translation to German, and some other stuff. When it is done, I will use the extension on my blog as well.

Tags:

Deleting many ListItems / SPFiles

René Hézser

Deleting a large amount of items in SharePoint can take some time. There are several ways on how to delete items:

  1. Deleting items using the OM with list.Items.DeleteItemById(itemID);
    • Deleting items using the SharePoint Webservices

      • Deleting items using the OM with web.ProcessBatchData(caml);
list.Items.DeleteItemById(itemID);

You should not use the Items property of a SPList multiple time. Instead create a variable, which stores list.Items and use it instead.

Deleting items using the SharePoint Webservices

FilterParts for SharePoint

René Hézser

A while ago Microsoft released some filter Webparts on MSDN.

SharePoint Filter Webparts including:
– BDC MultiFilter: Similar to the BDC Data Item Builder web part provided with MOSS 2007 Enterprise Edition, except it provides up to 4 additional filter connections containing BDC entity attributes to allow display of more entity-related data
– ShowFilter: Diagnostic display of any filter connected
– ShowFilterMap: Displays a Virtual Earth map when passed a filter containing a street address
– ShowFilterSearch: Displays MOSS search results when passed a filter connection containing a search query