Thursday, October 16, 2008

Creating tasks inside a while activity of workflow

In many of the workflow based projects, one of the important workflow functionality used is "tasks creation". Many times these tasks will be created repeatedly for every process completed by the workflow.
In these kind of scenarios we may require the task creation inside a loop, using "while activity" or the "replicator activity". But if you would like to use the "Create Task" activity inside the "while activtiy", make sure you are doing the following settings correctly otherwise workflow will create the task first time but it will give the error in the subsequent loops.
1. Keep all the task related activities (mostly, "create task", "onTaskChanged" and "complete task") inside a Sequential activity.

2. Use a separate correlation token for the activities inside the "Sequential activity"

3. For all the activities inside the "Sequential activity", Change the Owner activity property value to the sequential activity(this is important)

Following picture shows a simple workflow which contains the "create task" activity inside a while loop. Note that all the task related activities are kept inside the "Sequential activity".


This picture shows the properties of "create task activity". Owner activity name and correlation tokens should be changed as shown in the picture. This needs to be done for all the task related activities inside the "Sequential activity"

Tuesday, October 7, 2008

Create feature.xml for workflows using Code Snippet feature

While creating feature.xml or other XMLs from scratch, many people will be feeling a kind of difficulty. Well, this may not be applicable for people who live with visualstudio :). However while starting from scratch i noticed many of the developers are looking for a copy of feature.xml in features folder or somewhere else.

There is a very easy way to get your code snippet using visualstudio Code Snippet Manager.

1.Open your project in Visualstudio and add a new xml file

2.Press Ctrl K, Ctrl B. It should open Code Snippets Manager. We can also open this from Tools--> Code Snippets Manager menu.

3.Select XML from the Language drop down. Click on the Add button.

4.Select "C:\Program Files\Microsoft Visual Studio 8\Xml\1033\Snippets\Windows SharePoint Services Workflow" folder and "C:\Program Files\Microsoft Visual Studio 8\Xml\1033\Snippets\SharePoint Server Workflow"
Note: The second one is bit descriptive and it will come up with tags related to InfoPath forms and details about receiver class and assembly.




5.Right click in editor and select "Insert Snippet" from the context menu.


6.Select the feature.xml snippet. It will give us the Feature.xml we just need to fill up the template.

Friday, October 3, 2008

XML intellisense support for feature.xml file

This might be a well known point for developers who are already familiar in visual studio development environment. I am just putting this point for the beginners.

This is not specific to feature.xml file. We can use the same technique to get the intellisense support for other XML format files, the point is we need to select the appropriate schema files.

For feature.xml we need to do the following steps to get the intellisense support.

1.Add a blank XML file to your existing visual studio project and save it as feature.xml.

2.Select the properties of the feature.xml file.(F4) and click on the "schemas" property. a dialog box should open.

3.Click on the Add button.

4.Select the wss.xsd file from the Share Point schema location "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\wss.xsd"

5. Make sure the wss.xsd is selected in the "XSD Schema" window. Click on OK.


Now you should be able to use the Intellisense support for feature.xml file and other WSS related XML files

Monday, September 29, 2008

How to see workflow log history

While creating the workflows, one of the activity used frequently is log workflow history activity. This will log the information into the workflow history list. This is one of the feasible option for tracing the workflow process or activities. If the workflow process is bit lengthy with lot of branches this is going to help you lot.

But how to see the log history, If you click the workflow status column (for eg:"completed"). It will just show only the latest log history of the workflow instance executed and tied to that particular item. We need to check separately for other items.

Many times We will be requiring the entire workflow history to troubleshoot if any problems during the issues. This stored in a list called "workflow History". But if you check the "view all site content option" of your site you can't see the workflow history list. It is because the workflow history list is hidden and it will not be visible in the "view all site content option".

Still we can see this list by directly typing the URL. The below URL is showing the workflow history list of my site,
http://abcdomain:6666/sites/abcsite/Lists/workflow%20history/AllItems.aspx

Adding link in List Item context menu

Many times during the customization of WSS sites, we will be getting requirements to add different links in the context menu[Edit control block] of list items. There are different ways to do that. However adding this menu item as a feature is really looking cool, following simple feature will make this understand better.

1. Go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES folder and create an new feature folder called "AddCommunication"

2. Save the following code as feature.xml (update the GUID using GUID generator) into"AddCommunication" folder

3. Save the following code as Add Communication.xml in to the same folder

4. Install the feature.
stsadm -o installfeature -filename AddCommunication\feature.xml

5. Activate the feature
stsadm -o activatefeature -filename AddCommunication\feature.xml -url http://mysharepointsitecollection/

6. Go to your site and check the list item context menu drop down. This should look like the below image

This can be also done by using Java script easily, but for me feature is looking more convenient. I found a good article explaining this in Java script way
http://sizzlingpassion.spaces.live.com/blog/cns!E5CD42098EED7323!266.entry

Apart from the edit item context menu, this kind of links can be added in many menu types available in a WSS site. We need to select the correct group id of the document library or list library. A good microsoft step by step tutorial is available to understand this better.
http://msdn.microsoft.com/en-us/library/ms473643.aspx