Wednesday, January 14, 2009

MOSS Configuration: How to view the real exception behind the displayed custom error page?

A. Overview For a SharePoint developer, the error message An unexpected error occurred is useless! A developer needs to get details about the error that has occurred, at least the exception's call stack. When installing MOSS, the default configuration is that the Call Stack is deactivated and the custom error pages are turned on. This is completely correct, because this is how you would wish to have it on your production system. Now comes the question: How should I -as a developer- change the default configuration on my development environment? B. Configure your development environment 1. Open the web.config file Path: C:\Inetpub\wwwroot\wss\VirtualDirectories\80\web.config 2. Turn on the call stack - Search for safemode element. - Change CallStack="false" to CallStack="true". 3. Turn off the custom error pages - Search for customerrors element. - Change mode="On" to mode="Off". 4. Enable debugging and batch compilation - Search for compilation element. - Change batch="false" debug="false" to batch="true" debug="true". C. Test your configuration - Browse the page that has previously thrown the "An unexpected error occurred" message. - You should now see the yellow ASP.NET page with the true exception and underlying call stack.

Friday, January 2, 2009

SPD Workflow: How to create a formatted body for the Send Email task?

A. Overview

The Send Email is a very popular action for SPD workflow developers. Unfortunately, the Editor of the e-mail body doesn't contain any formatting tools. That's a lot of luxury to ask for. But as the need arises, I have written this article to provide the steps for creating formatted e-mail bodies in the Send Email action.

I have taken the idea and some of the content of this article from an Office Online video tutorial with the title Watch this: Design a document review workflow solution.


B. Design the HTML needed in the body

1. Open Microsoft Office SharePoint Designer 2007.
2. Click File > New > HTML, in order to create a new HTML page.
3. A new panel opens. In the bottom left corner of this panel, make sure that the Split View is selected, as shown in the following figure.


IMPORTANT NOTE:
There are two considerations when you use HTML in workflows:

Consideration 1:
Workflow e-mails do not support class-based styles. All the formatting must be done using inline styles.
The following configuration steps should be performed:
- Click the Style Application icon on the bottom bar.
- Make sure that Style Application is set to Manual and the Target Rule is set to New Inline Style.


Consideration 2:
Any white space will affect how the designed HTML will be displayed. Therefore, it is recommended to remove it.
This can be done easily by performing these steps:
- Click Tools > Optimize HTML.
- In the Remove Whitespace section, select HTML all whitespace.


- Click OK. You can see that all the whitespace has been removed from the HTML code in the Code Pane.

To get the formatted text again, you should follow these steps:
- Select the text in the Code Pane and right-click it.
- Click Reformat HTML.


Now let's continue designing our HTML for the e-mail body.
5. Delete the default text in the Code Pane.
6. Copy and Paste the following text as an example in the Code Pane.



7. Click anywhere in the Design Pane, in order to see how your mail body would look like.
8. Perform the changes you wish.
9. Now remove the whitespace as explained in the previous Note section.
10. Copy your HTML code to a text file and save it, in order to be used later in the workflow.


C. Create the workflow

1. Click File > Open Site.
2. Enter the URL of the site containing an announcement list, on which we shall perform our test.
3. Now click File > New > Workflow.
4. On the Define your new workflow page, enter the following data:
  • Name: FormattingMails
  • Attachment List: Announcements
  • Start Options: Automatically start this workflow when a new item is created
5. Click Next, in order to start designing the workflow steps.
6. Enter Send formatted Mail Body as the Step Name.
7. In the Actions section, select the action Send an Email.
8. Click the this message link.
9. Fill the To and Subject fields with appropriate values.
10. Paste the HTML code which was designed in section B into the Body area.
11. Repalce the fields marked by [*****LOOKUP******] with the correct values using the Lookup wizard.


12. Click OK to close the message builder.
13. Click Finish to save and publish the workflow.


D. Test the solution

1. Browse the site containing the annoucenemnts list to which the workflow was attached.
2. Open the Annoucements list.
3. Create a new entry.
4. Check the body of the sent e-mail notification.

MOSS Configuration: How to display announcements on the home page of a Publishing Portal?

A. Overview Recently, I have encountered the question of how to add an announcements web part on the home page of a Publishing Portal. The same question arises for Calendar, Contacts, Discussion Board, Survey and a set of other lists, which belong to the so-called Team Collaboration Lists. As the title conveys, in this article I shall provide the steps for adding an announcements web part on the Home Page of a Publishing Portal. The exact same steps should be applied for displaying any other Team Collaboration List. In the last section of the article, I provide a note about how to accomplish the same task on a Collaboration Portal B. Create an Announcements list B.1. Steps for creating an Annoucements List: 1. Browse the Home Page of the Publishing Portal. 2. Go to Site Actions > Site Settings > Modify All Site Settings. 4. Under Site Administration, click Site Libraries and lists. 5. Click Create new content. PROBLEM: You would not find the Announcements list, as shown in the following figure. The reason for this problem is that the Team Collaboration Lists Feature is not activated by default on a Publishing Portal. The next section would show you how to activite this feature. B.2. Steps for activating the Team Collaboration Lists Feature 1. Go to Site Actions > Site Settings > Modify All Site Settings. 2. Under Site Administration, click Site features. 3. Activate the Team Collaboration Lists. 4. Now repeat the steps for creating an Annoucenemts list which are described in section B.1. and you would find the Announcements under the Communications section, as shown in the following figure. C. Add the Announcements on the Home Page With section B finished successfully, the new announcements list has been added as content to the portal site. Now we would add a web part to view the content of the announcements on the Home Page. This can be accomplished by performing these steps: 1. Browse the Home Page of the Publishing Portal. 2. Go to Site Actions > Edit Page. 3. From the Page menu, select Add Web Parts and click Browse. 4. Click the Filter icon in the Add Web Parts pane. 5. Select Lists from the Show drop down list. 6. Select the announcements list created in section B. 7. Click the Add button. D. What about Collaboration Portals In a Collabortaion Portal, the Team Collaboration Lists Feature is activated by default. Thus, you can follow the same steps described in section B.1. for creating a new announcements list, without having to activate the feature first (as described in section B.2.). Finally, you would add the announcements web part on the Home Page by following the same steps described in section C.

SPD Workflow: A workflow does not start automatically

A. Overview Last week, a colleague of mine has encountered a problem with workflows authored in SharePoint Designer. When a workflow is configured to start automatically when a new item is created or changed, the workflow does not start as expected and the log file does not contain any error messages. However, if you start the workflow manually, everything works just fine. Afer some analysis and search, the problem was resolved. The following sections contain details about the source of the problem and all the symptoms, the cause of that problem and finally the fix. This information is taken from an article on Microsoft's Help and Support site. B. Symptoms After you install Windows SharePoint Services 3.0 Service Pack 1 (SP1), a declarative workflow does not start automatically in the following products:
  • Windows SharePoint Services 3.0
  • Microsoft Office SharePoint Server 2007
  • Microsoft Office SharePoint Designer 2007
For example, if you configure a declarative workflow to start when a new item is created or when a new item is changed, the declarative workflow does not start as expected. The Unified Logging Service (ULS) log files contain no information about why this behavior occurs. C. Cause This behavior occurs because a security fix in Windows SharePoint Services 3.0 SP1 prevents declarative workflows from starting automatically under the system account. After you install Windows SharePoint Services 3.0 SP1, declarative workflows do not start automatically if the following conditions are true:
  • The Windows SharePoint Services Web application runs under a user's domain account.
  • The user logs in by using this domain account.
  • The site displays the user name as System Account.
D. Resolution To resolve this behavior, set the application pool account to use a different user account. You may want to create a new user account specifically for this purpose. To set the application pool account to use a different user account, follow these steps:
  1. On the server that is running one of the products that is listed in the "Applies to" section, click Start, point to All Programs, point to Microsoft Office Server, and then click SharePoint 3.0 Central Administration.
  2. Click the Operations tab.
  3. Under Security Configuration, click Service Accounts.
  4. Click Web application pool, and then click Windows SharePoint Services Web Application in the Web service box.
  5. In the Application pool box, click the application pool that you want to change.
  6. Under Select an account for this component, click Configurable, and then type the user name and the password for the different user account.
Note that the fix applies to:
  • Microsoft Windows SharePoint Services 3.0
  • Microsoft Office SharePoint Designer 2007
  • Microsoft Office SharePoint Server 2007