SharePoint 2013 Workflow Errors

SharePoint 2013 Workflow Tips

I have learned some gotchas and tricks while creating my first SharePoint 2013 Workflows.

Background:

These observations were observed while using SharePoint Designer 2013 with Service Pack 1 to create SharePoint 2013 Workflows on an on-premises farm running version 15.0.4665.1000 ​(2013 Service Pack 1 Mark 2).  No custom visual studio actions have been used.

Observation 1:

Corrupt workflows:

DO NOT copy and paste Conditional IF statements from one stage transition to another stage transition.

This may cause the workflow to become corrupted.  I have attempted to save the workflow as a template periodically in case it becomes corrupted later.  THIS DID NOT WORK.  It appears that workflows can become corrupt and nothing I could do later helped.  This included exporting the WSP, unpacking it, then trying to copy the XAML from one workflow to another and redeploy to the system.  Basically I tried every workaround I discovered.  Even tried using SharePoint Designer from another computer and server even.  I have rebuilt this workflow 5 times because of corruptions!

DO NOT delete a stage with nested transactions/steps inside.

This may be alleviated by deleting the actions inside a stage prior to deleting the stage.  In fact I have become scared to use copy and paste on anything but single actions.

Reference: http://blog.eastridge.net/corrupted-sharepoint-2013-designer-workflows

Note:
These may be fixed by a later update to SharePoint Server or SharePoint Designer.  I cannot confirm this, but if someone knows please tell me so I can update this blog!

Observation 2:

Email Send Error causes Workflow to cancel:

If you wish to send an email to a person lookup, use the "Login Name" and not anything else, or the system will detect a NULL value in the sendto field and retry 4 times before canceling the entire workflow.

Example:

I use variables to reduce the amount of lookups the system has to perform.  The important thing to remember is to Return field as: Login name.  In my example I write the value of an SPUser object (a Person Lookup) to a string variable as the Login Name.

Observation 3:

There is a Limit to the Number of Variables Allowed!

Apparently this is 50.  Seriously?  Variables are much more important in 2013 workflows as I use them to pass information between stages.

Here is the error you receive when you Publish the workflow with too many variables:

Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors:
Activity 'DynamicActivity' has 52 arguments, which exceeds the maximum number of arguments per activity (50).

Observation 4:

Active Directory Groups cannot be USED!

Sorry.  I tried it and they failed over and over until I created a SharePoint Group with explicit users listed.  It did not work when I tried to add an AD group inside a SharePoint Group.

Observation 5:

Send email activity fails if the Email Address is NULL.

This is rather obvious, that the send email activity cannot send an email to a NULL value, but the entire workflow is cancelled after the system reattempts the activity multiple times.

I do a condition check, to see if the account has a non-empty email address.  If it does I write an error message, set it to a variable called: "stringErrorMessage" and in the Transition to Stage I write the same condition to send the workflow to an ERROR stage which writes the Workflow Status = Workflow Error, and then logs to the history list the stringErrorMessage contents.

Send Email Error Handling:
Error Check for Email Address = NULL
ERROR Stage:
ERROR Stage

Comments

Popular posts from this blog

SharePoint Designer 2013 Approval Workflow with Comments

Change SharePoint server hostname and Web Application Names

SharePoint Search - Content Processing Pipeline Failed to Process the Item