Showing posts with label Workflow. Show all posts
Showing posts with label Workflow. Show all posts

Thursday, January 10, 2013

Sharepoint Fault Handler in vs 2008

Please see  Sharepoint Fault Handler in vs 2008

Also below is a copy.

Fault Handler
To get more detailed information about this error, it is necessary to add a Fault Activity (equivalent of a catch block) and to log it.
Select the workflow in the (Visual Studio) Workflow Designer, click on the lower left side of the Designer and click on the Fault Handler:
image
Another view of the Workflow Designer will show up:
image
Drag and drop a FaultHandler activity from the Workflow Foundation toolbox into  fautlHandlersActivity1 :
image
In the property page of this last activity select the FaultType property by browsing the mscrolib assembly:
image
Select System.Exception:
image
Now we will log the StackTrace into the workflow history log: drag and drop a LogHistoryList activity into the handler (if you don’t find this activity drag and drop the microsoft.Sharepoint.WorkflowAction.dll assembly to a new Visual Studio toolbox tab) :
image
Select the logToHistoryListActivity1 and set its HistoryOutcome property to the stack trace value of faultHandlerActivity1:
image
image
Rebuild the solution , redeploy (install.bat) and test the workflow.
The trace will show up in the workflow status :
image

Tuesday, December 18, 2012

Controls on the InfoPath Task Edit Form Not Persisting Values

The SharePoint 2010 Visual Studio workflow uses an InfoPath form as the task edit form. On the form, values of some of the controls are persisted once the task edit form is submitted, but values of some other ones are not. For instance, input a value into a textbox then submit the task edit form, then open the task edit form again, the textbox is empty, the inputted value is gone.

It turns out that the problem is caused by the column name of the task list of the workflow. Let's say there is a textbox on the InfoPath task edit form, the textbox is bound to ClientName field and default value for ClientName field is ows_ClientName via the ItemMetadata.xml file. If the workflow task list has a column named ClientName, then the value of the textbox is not persisted. For unknown reason, the workflow engine can't process ExtendedProperties["ClientName"] correctly.

Solution: The column name of the workflow task list should not be the same name from ItemMetadata.xml file, without the ows_ prefix, if the value of the control bound to the entry in ItemMetadata.xml file needs to be persisted.

Friday, October 12, 2012

How to rename the automatically generated task form in SharePoint Designer workflow



In SharePoint Designer click on All Files in the Site Objects. In the All Files tab navigate to Workflows and click on your workflow. You should see the xoml file, the rules file, the xsn forms and a wfconfig xml file.

To rename the xsn form, update the wfconfig xml file. Replace the old name with the new one. That xml file contains the content type related to that task, so you can also change the contenttype name as the 'WorkflowForm' name. After saving the wfconfig xml file you need to restart SharePoint designer and you should see your form with the new name.

You need to be the site administrator in order to see the All Files link un Site Objects. 

Also it looks like that Lookup type does not work in Task Form Fields, i.e., you can't have lookup type field in task form. If you do, you may see "SharePoint Designer encountered an error generating the task form" error message.

Thursday, October 11, 2012

SharePoint Designer Workflows Process Identity

When a SharePoint Designer (SPD) workflow runs, it runs in the context of the workflow initiator. This is important to know if the initiator may not have permissions to everything that the workflow does.

See SharePoint Designer Workflows – what user identity?

SharePoint Designer 2010 introduces the new impersonation step. Please note that the impersonation step can be run only as the user who authors the workflow. The author of the workflow, most likely, is not the same as the identity of the SharePoint timer job. 

Wednesday, March 28, 2012

SetState activity fails using one of the predefined SPWorkflowStatus enumeration values

Get the following error message: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.     at Microsoft.SharePoint.Workflow.SPWorkflow.SetIStatus(Int32 i, Int32 iStatus)

Workaround: use custom values, see below:

<ExtendedStatusColumnValues>
<StatusColumnValue>CustomStatusStatusColumnValue>
ExtendedStatusColumnValues>

Wednesday, October 27, 2010

How to solve Microsoft.SharePoint.SPException: A file with the name xxx already exists. It was last modified by SHAREPOINT\system on xxx

In the workflow, if the workflow needs to update the column/field of the current workflow list item, i.e., workflowproperites.listitem, workflowproperties.listitem.update() will cause above exception. To solve this problem, the workflow needs to retrieve the listitem independently, as suggested by this blog by


My resolution is to add a simple property to my WF class. What it will do is ensure that I always load up the SPListItem every time I need it.

private SPListItem WorkflowItem
{
    get
    {
        SPDocumentLibrary library = (SPDocumentLibrary)WorkflowProperties.Web.Lists[WorkflowProperties.ListId];

        return library.GetItemById(WorkflowProperties.ItemId);
    }
}


There are many suggestions about how to fix this problem, but this one did it for me.

Friday, October 15, 2010

Start SharePoint Workflow from Web Services

Just some quick points:
  • I place the web application with the web services under the same application pool of SharePoint, also in the web services I use SPSecurity.RunWithElevatedPrivileges. Otherwise, you may run into the error message like the following: System.IO.FileNotFoundException thrown by the SPSite constructor.
  • Also I enabled web.AllowUnsafeUpdates so that to not run into security validation error.