I’ve been meaning to get caught up on blogging for a while now but it seems like the need to be productive has overwhelmed the desire to get some of the challenges I’ve run into written down. As it happens, however, I just got derailed by another issue, so it’s a perfect time to reflect upon some of the issues I found, and resolutions to them. (I’ll post the resolution to my latest issue sometime after I get it.)
- Issue: If you define a field <Field> with a ReadOnly attribute it doesn’t show up in the interface anywhere.
Resolution: Set the field as ReadOnly in the <ContentType> <FieldRef> instead. This allows it to appear. (Thanks Manish.)
- Issue: If you make changes to a <Field> definition it isn’t seen.
Resolution: Add the DisplaceOnUpgrade=”TRUE” attribute to force the updates to be seen.
- Issue: Changes made to a content type aren’t seen by a list the content type was already associated with.
Resolution: Remove and reassociate the content type with the list from the user interface. (Sorry, I don’t have a programmatic resolution to this one.)
- Issue: Receive an exception “SPException: This task is currently locked by a running workflow and cannot be edited.” while trying to edit a task.
Resolution: Workflow locks the tasks it creates – except from within the context of an UpdateTask, an OnTaskChanged, CompleteTask, or RollBackTask activity. If you’re trying to modify the workflow from the web/user interface, make sure that the workflow is in a listen activity listening for a OnTaskChanged event. If you’re in the workflow itself you’ll need to do it from an UpdateTask activity.
- Issue: My changes to a task inside an UpdateTask activity aren’t recognized.
Resolution: Use the SPWorkflowTaskProperties object attached to UpdateTask to update the task properties. These will be written out during UpdateTask and since they’re not synchronized to the list item, they will be out of sync and overwrite your changes.
- Issue: Some of the fields in my task are getting overwritten when I do an UpdateTask in the workflow.
Resolution: UpdateTask writes out whatever is in the SPWorkflowTaskProperties – including extended properties – and since these are not synchronized with the task itself – may be out of date. Make sure that you write out the correct values to SPWorkflowTaskProperties so they are updated correctly.
- Issue: I’m using SPListItem.SystemUpdate() and the workflow OnTaskChangedActivity fires.
Resolution: I don’t know. Even SystemUpdate() seems to trigger the OnTaskChangedActivity.
- Issue: Fields that are in the task list aren’t being displayed in the edit or display forms for the workflow tasks created.
Resolution: Workflow tasks are designed to work with a specific content type. This content type is added to the task list – even if managing content types is turned off. The display form and edit form are the forms associated with the content type. To get more fields to be displayed and to be editable define your own content type. Then either specify the TaskListContentTypeID attribute of the <Workflow> node in the element XML file or use the CreateTaskWithContentType rather than CreateTask activity.
- Issue: My workflow is completing but isn’t going through the entire path – or my fault handler.
Resolution: In my particular case, I had an issue with serialization where one of the properties of my custom activity (to send email) wasn’t serializable. However, the reported exception wasn’t the actual exception being raised and it was recorded in the ULS. Verify that your custom activities can serialize correctly.
- Issue: SPWorkflowTaskProperties.ExtendedProperties aren’t populating the fields in my task.
Resolution: In my particular case, I had somehow managed to get multiple fields in the task list with the same name. (I’m not sure how precisely.) I deleted the extra fields and CreateTask started populating the fields in the task.