Dailycode.info

Short solution for short problems

Unexpected error on server associating the workflow

Ever had this nice error:

I first got this error when I was migrating the workflow from development to live. I just copied the workflow and linked the list and items correctly. When I press finish it saves the changes but cannot associate the workflow with the list. The problem was because it was the first workflow on the site, there was no folder created for the workflows. A copy paste, copied the workflow in the root directory. Look for the difference in the pictures below!

This doesn't work:

This works:

In both pictures you will find a workflow folder, this was because I had taken the screen after the folder was created. But I dragged the workflow to the root and the same problem arrose. So the solution is to put the workflow in the correct workflow folder. If it does not exists yet:create a dummy workflow and the system will create the workflow folder for you. Then drag your workflow in this folder and now it can associate the workflow with the list. Remove the dummy workflow.


SPListItem.Copy()

This function can copy a listitem from one list to another. After a little debugging and googling I noticed that the url field has to be the complete field. The target list can contain less or more columns, it just copies the they share. Very simple implementation:

SPListItem.Copy(SPContext.Current.Web.Url + "/" + doc.Url, _publicLibUrl +doc.Name);

I made the destinationurl of the library a public property of my webpart. So I can use the webpart on any site. I'm still trying to find out if there is a possibility to overwrite documents. At first site it looks impossible. Any help on this is welcome.(workaround below) It is no problem to copy the item from one site to another on the same server.

I do this at the end of my approval workflow. When the document is approved and published, I copy it to document library on an other site, where all users have read acces. Togehter with RMS we can lock the files completely. When a reviewer changes things in the document, users won't notice it. Only after final approval, the document will be copied to the public library. This creates a working version and a published version.

Added on 8/7/2008 

So I found a workaround for the SPListItem.Copy overwrite problem. First I tried the SPFile.CoptTo. This can overwrite the file but cannot copy to another site. Then I tried the SPFileCollection, but there the overwrite problem arrose again. So now I created a simple workaround, because I don't need versions I look for and delete the file before I copy it. The versions are kept in the original library.

SPSite site = SPContext.Current.Site;

SPFile file = site.AllWebs[_sopSiteName].GetFile(_publicLibUrl + doc.Name);

if (file != null)

{   

file.Delete();

}

SPListItem.Copy(SPContext.Current.Web.Url + "/" + doc.Url, _publicLibUrl +doc.Name);

 


Open document in Edit mode: DispEx

Frustrating, this is what Sharepoint sometimes can be. Today I realised that the workflow I created on a document library (in Sharepoint Designer) is not able to fulfill our needs.

The story:

When you assign a Todo item, or a create task, the system creates a link to the document. When a user clicks on the link, a read only version is opened in a browser. The task should be review. So if the reviewer open the task, he clicks on the link to review the document. Then he makes changes and when he is finished, he clicks Ctrl-S, nothing happens. In the menu, only the save-as button is enabled. When he browses for the correct document library and tries to save the document, the system asks him to overwrite. He chooses Yes. Then a friendly pop up tells him the document is a read only version. Hahaha he smiles, I can start over. This is not what I had in mind. I was hoping the document could be opened(not in a browser but in Word) and saved.

So as a solution, I choose to open a link to a webpart, on which I created a link t the document. Using the DispEx function, the document is opened in Word and the reviewer only needs to press Ctrl-S and it is saved as a new version on the correct place.

Here the code:

public class OpenDoc : WebPart
    {
        string sSOPURL = null;
        string sSOPName = null;
 
        private string GetSOP()
        {
            if (String.IsNullOrEmpty(sSOPName))
            {
                sSOPName = this.Page.Request.QueryString["qSOPName"];
                if (String.IsNullOrEmpty(sSOPName))
                {
                    sSOPName = "noSOPsel";
                }
            }
            return sSOPName;
        }
 
        private string GetSOPURL()
        {
            if (String.IsNullOrEmpty(sSOPURL))
            {
                sSOPURL = this.Page.Request.QueryString["qSOPURL"];
                if (String.IsNullOrEmpty(sSOPURL))
                {
                    sSOPURL = "noSOPurl";
                }
            }
            return sSOPURL;
        }
 
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            try
            {
                if (GetSOP() == "noSOPsel")
                {
                    writer.Write("<br>");
                    writer.Write("<br>");
                    writer.Write("<center>");
                    writer.Write("To open an SOP, click below");
                    writer.Write("<br>");
                    writer.Write("<br>");
                    writer.Write("</center>");
                }
                else
                {
 
                    writer.Write("<br>");
                    writer.Write("<br>");
                    writer.Write("<center>");
                    string url = GetSOPURL();
 
                    if (url.EndsWith("doc") || url.EndsWith("docx"))
                    {
			//This is were we write the code to open the document in edit mode
                        writer.Write("<A onfocus=\"OnLink(this)\" HREF=" + url + " onclick=
\"return DispEx(this,event,'TRUE','FALSE','TRUE','','0','SharePoint.OpenDocuments','','','',
'21','0','0','0x7fffffffffffffff')\">" + GetSOP() + "</A>");
                    }
                    else
                    {
                        writer.Write("<A target='_blank' HREF='" + url + "'>" + GetSOP() + "</A>");
                    }
                    writer.Write("<br>");
                    writer.Write("<br>");
 
                    writer.Write("<br>");
                    writer.Write("<br>");
                    writer.Write("</center>");
                    RenderChildren(writer);
 
                }
 
            }
            catch (System.Security.SecurityException x)
            {
                writer.Write("Sec Error: " + x.ToString());
            }
            catch (Exception er)
            {
                writer.Write("Error: " + er.Message);
            }
        }
    }

In the workflow I create a task for the reviewers, in the description I put a link to a page holding this webpart. The document URL and Name are provided as querystrings to this page.


How to configure pdf filter for WSS 3.0?

Follow these steps to configure the ifilter: 

First, you need to download the Adobe PDF IFilter 6.0, which you can find at this URL.  You should also get hold of a suitable Icon to use with PDFs, so that when they are listed in a document library they are easily recognisable.  There is a 17 x 17 one available on the Adobe web site here.

Once you’ve downloaded the IFilter, install it on your WSS 3.0 server, and then follow the instructions on registry settings in Microsoft KB Article 927675.  I’ve always found that providing the Adobe IFilter installed properly, the only setting I need to add is the Search Extensions. Also note re stopping and re-starting the search service at the end of this article.
Now you need to set up the Icon file. 

If you downloaded the icon file in step 1 above, you will have a file called pdficon_small.gif.  You need to copy this onto your WSS 3.0 server, into drive:\Program Files\Common FIles\Microsoft Shared\Web Server extensions\12\TEMPLATE\IMAGES.

Next you need to edit the XML file which WSS uses to link file extensions to icons.  This file is called DOCICON.XML and is located at drive:\Program Files\Common FIles\Microsoft Shared\Web Server extensions\12\TEMPLATE\XML.  Navigate to that folder and locate the file.  I would suggest making a backup copy first, then opening the file in NotePad.  You need to add a mapping key for PDFs at the bottom of the file, above the </ByExtension> closing tag.  The new key will be <Mapping Key=”pdf” Value=”pdficon_small.gif” OpenControl=”"/>  (note that XML is case sensitive so make sure you use same case as previous entries).  Then save the file.

If you already have PDFs uploaded to your WSS server I would recommend starting a full crawl.  You can do the with STSAdm, the command syntax is Stsadm -o spsearch -action fullcrawlstart .

When you notice that pdf documents are crawled and showed by the WSS search, but still the icon doesn't show up. If you triple checked the DOCICON.xml file and if the image is correct and IISRESET doesn't change a bit, then maybe this can help:

Create a new site collection. check if the pdf icons are showed in this new collection. Now return to the old site collection, normally the icons should now show up. In my case this helped!


Search service won't start

After you installed WSS on your server, you start configuring. At a point you want to configure the search service, but you can't find the place where you need to configure this.

In your central administration, go to the home page. Then you will find under server topology the name of the server where you installed WSS on. Click on the name and you will be forwarded to the page where you can configure the services on the server. You will notice that the search service is stopped.

When you try to configue this service, it could happen that a general error message is shown. When you click help, you'll get the default WSS help with nothing on this problem. It's hard to google for this problem because you can't find a good error explanation.

When you were lucky and found this post. Try to add the domains before the user names. In my case it solved the problem. Even if it is a local user, place the computer name before the user. To bad WSS doesn't give a simple error like: "unknown user". You don't have to do this for the SQL user when you use SQL authentication.


Send email to user group in Sharepoint Workflow

Should be easy, yes, but can be difficult. When you notice no email is sent, but no error message is delivered. Maybe this can help the ones who are having simular problems:

There are 2 settings you have to make in your Sharepoint user group, the first one is to give everyone view acces to this group. Like this:

Then the user group should have read permissions on the site.

Now the workflow can send email's to sharepoint groups.


How to rename workflow in sharepoint designer?

Although the function: Rename is available by rightclicking the workflow name, it will not correctly rename the workflow. The problem is that it only changes the title but in the config file, still the old name exists. We will need to perform some manual tasks after you renamed all the files!

Open the OLDWFName.xoml.wfconfig.xml file.

Change the path name to the new name. I will give an example below.

OLD name was New SOP WF, new name is: SOP WF

Old config file was:

<WorkflowConfig>
    <Template        BaseID="{FD02CD7B-DE27-486F-BF2B-65E807ACD1E4}"
        DocLibID="{F1E7A575-B9D8-415B-9BF7-7BD5CC293DD0}"
        XomlHref="Workflows/New SOP WF/New SOP WF.xoml"
        XomlVersion="V75.0"
        RulesHref="Workflows/New SOP WF/New SOP WF.xoml.rules"
        RulesVersion="V75.0"    >
    </Template>
    <Association        ListID="{DB955486-0511-44DD-ACE4-B1649ACF4859}"
        TaskListID="{40FC9FF0-2B2F-4825-A184-49E772277C1F}"
        StartManually="true"        StartOnCreate="true"    >
    </Association>    <ContentTypes>        ... 
    </ContentType>    </ContentTypes>
    <Initiation URL="Workflows/New SOP WF/New SOP WF.aspx">
        <Fields/>
        <Parameters></Parameters>
    </Initiation></WorkflowConfig>

 

The new config file looks like this (I placed the part I changed in bold):

<WorkflowConfig>
    <Template        BaseID="{FD02CD7B-DE27-486F-BF2B-65E807ACD1E4}"
        DocLibID="{F1E7A575-B9D8-415B-9BF7-7BD5CC293DD0}"
        XomlHref="Workflows/SOP WF/New SOP WF.xoml"
        XomlVersion="V75.0"
        RulesHref="Workflows/SOP WF/New SOP WF.xoml.rules"
        RulesVersion="V75.0"    >
    </Template>
    <Association        ListID="{DB955486-0511-44DD-ACE4-B1649ACF4859}"
        TaskListID="{40FC9FF0-2B2F-4825-A184-49E772277C1F}"
        StartManually="true"
        StartOnCreate="true"    >
    </Association>
    <ContentTypes>        ... 
    </ContentType>
    </ContentTypes>
    <Initiation URL="Workflows/SOP WF/New SOP WF.aspx">
        <Fields/>
        <Parameters></Parameters>
    </Initiation></WorkflowConfig> 

/3GB option in the Boot.ini (cannot open large files)

I installed WSS 3.0 on a windows 2003 server. Everything looked OK. I was thrilled to get the installation so easy and correct in the first try. But when I start using Sharepoint, I noticed that some files opened and other didn't. What was going on here? After digging for hours in the WSS administration, I couldn't find the problem. Then I started to google for a solution, but I can tell you, it was not easy. After testing a little while I noticed that files larger then 200Kb didn't open, smaller files did. So There was some kind of limitation on the server. I noticed that the files where correctly in the DB. So I concluded that it was not a Sharepoint problem. When I finally hit the correct search words in google I came up with this solution:

The Windows Server 2003 /3GB switch is not supported in Windows SharePoint Services 2.0 or in later versions or in SharePoint Portal Server 2003 SP2 or in later versions.

Look for more here: http://support.microsoft.com/kb/933560

So when I removed the /3GB part in the boot.ini file and rebooted the server, everything works fine. What a relief. I hope you didn't had to google as long as I did to find this solution!

//Added on 11/08/2008 by Mark Deraeve

I had the same error working woth word documents. But the error messages can be very misleading. Here are some examples of error messages:

or:

If you are having this kind of errors or even an error like: locked of checked out by ... and it doesn't make sense, then try firdt opening a small or empty document. If that works, you know it is this problem and you know the solution.

http://support.microsoft.com/kb/933560


MOSS 2007 list performance drop

Observation : MOSS 2007 list performance drop

Recently, we discovered that the performance of the MOSS 2007 implemenation of our client dropped significantly for a specific list. The list contains some 1200 records. Most of them contain attachments. The loadtime for the default view would extend to over 20 seconds. Switching views made things even worse!

Analysis

First, the server performance was consulted while loading the list. No special or irregular behaviour of the processor or memory. Services were checked to find out if a service like for example the search was performing a heavy index. No special observations. Then we placed indexes on the key columns. This made no visible difference in performance.

How is it possible that only that list is slow in loading, while other list and doclibs in that same site have a normal loadtime? It had to be something list-specific. And what is specific to a list?  It's views...

Interpretation : Optimizing the GROUP BY

After scrutinizing the views of that list, we discovered that the there were massive groups in certain views. The "group by" statement resulted in records being categorized in over 100 groups. Setting a limit to the number of groups improved performance drastically!
When showing 100 groups on a page, the loadtime took 15-20 or even more seconds. When tuning down the number of groups to 50, the page loaded under 10 seconds.

We tested further and discovered that the number of items under a group hardly alter the page loading time when the groups are collapsed on start. A page with 1 group and 500 items under it will load many times faster than a page with 500 groups and just 1 item under each of those groups.
The key is be wise with GROUP BY statements.

Conclusion : Relation between GROUP BY statement and load time

  1. Group your items in less then 50 categories for optimal performance
  2. Show as few groups as possible on a page (max 50 groups/page)
  3. Place column indexes on the columns you group by 

Applying these principles solved our issue on the spot...

We hope this information will help you further optimizing your WSS/MOSS 2007 environment.


Daily WSS: Web services

Web services

WSS 3.0 exposes the whole functionality of the site through web services making it very easy for 3rd party application to connect to the platform. You can manage documents, list, etc, via these web services. This can come is very useful to publish automatic generated reports. You can use the SharePoint search query to find certain documents or list items. The web services are better explained in the Microsoft SDK: http://msdn2.microsoft.com/en-us/library/ms441339.aspx Here an overview of the available web services with a short description.

Microsoft Windows SharePoint Services Web services provide methods that you can use to work remotely with a deployment of Windows SharePoint Services. The following table lists and describes the available Web services.

Service

Description

Administration

Provides methods for managing a deployment of Windows SharePoint Services, such as for creating or deleting sites.

Alerts

Provides methods for working with alerts for list items in a SharePoint site

websvcAuthentication

Provides classes for logging on to a SharePoint site that is using forms-based authentication.

Copy

Provides methods for copying items between locations in Windows SharePoint Services.

Document Workspace

Provides methods for managing Document Workspace sites and the data they contain.

Forms

Provides methods for returning forms used in the user interface when working with the contents of a list.

Imaging

Provides methods that enable you to create and manage picture libraries.

List Data Retrieval

Provides a method for performing queries against lists in Windows SharePoint Services.

Lists

Provides methods for working with lists and list data.

Meetings

Provides methods that enable you to create and manage Meeting Workspace sites.

People

Provides methods for working with security groups.

Permissions

Provides methods for working with the permissions for a site or list.

SharePoint Directory Management Service

Provides methods for remotely managing distribution groups.

Site Data

Provides methods that return metadata or list data from sites or lists in Windows SharePoint Services.

Sites

Provides a method for returning information about the site templates for a site collection.

Search

Provides methods for remotely performing searches within a Windows SharePoint Services deployment.

Users and Groups

Provides methods for working with users, site groups, and cross-site groups.

Versions

Provides methods for working with file versions.

Views

Provides methods for working with views of lists.

Web Part Pages

Provides methods to send and retrieve Web Part information to and from Web services.

Webs

Provides methods for working with sites and subsites.