Thursday, April 26, 2007

Updating an Item from a workflow monitoring the OnItemChanged event.

Scenario: Workflow is waiting on the OnItemChanged event of a SP list. We need to update the same item from the workflow.

Solution:
Do not use the Update method of SPListItem. This will surely make the workflow go into recursion.

Instead add a CallExternalMethod Activity.
Select the interface type as IListItemService
Method : UpdateListItem

Bind the following properties:
1. ListId : Bind to the workflowproperties.ListID
2. ItemId : Bind to the workflowproperties.ItemID
3. Id. : To a new GUID
4. itemProperties: This is an important property. This property holds the ColumnName,Value pair that needs to be updated.

Once you bind the itemProperties to a field, you can add columns and the their values like any other ArrayList/Dictionary.

Once this activity executes the list item gets updated.

NOTE: This solution does sometime make the workflow go into recursion. But this recursive behaviour is not consistent.

Wednesday, April 11, 2007

Capturing onItemChanged event in Workflow

To catch the onItemChanged event of any Sharepoint list in a workflow, the following needs to be done:

  • Add a CallExternalMethod Activity, set the interface to Microsoft.SharePoint.Workflow.IListItemService
  • Set the method name to InitializeForEvents
  • Bind the ItemId, ListId to ItemID and ListId in the workflow properties.
  • Add a HandleExternalEvent activity and specify the following properties:
    InterfaceType to Microsoft.SharePoint.Workflow.IListItemService
    Event Name : OnItemChanged
    NOTE: The correlationToken should be the same as the correlation token specified for CallExternalMethod activity.
    Method Name. This method will be called whenever there is a change in the list item.
  • This will capture the onItemChanged event.

Tuesday, April 10, 2007

Alernate URL Mapping and Custom ASPX Pages

Assume you have mapped a URL to a Sharepoint Site and are accessing the site from the extranet. This sharepoint site gets accessed locally from a port other than 80.
If you develop a custom aspx page then you would generally put the page in the _layouts folder and the dll in the Bin folder of the Site:port Virtual directory.
The page would work fine if the user accesses the site from the Intranet using the local url i.e http://site:port

But try accessing the page using the mapped URL. It wont work.

What I had to do was to put the Dll of custom page in the Bin directory of site at port 80. This got the page working.