If you ever have worked with or want to start working with SharePoint Designer 2013 workflows (good for SharePoint 2013, SharePoint 2016 and SharePoint Online as of July, 2018), here are some tips to use and traps to avoid.
Check for Errors before Save or Publish
At the start of a recent project, I received this error every now and then when trying to Publish (which executes a Save first).
"The workflow contains errors, but they are not visible in the current view". Sometimes (rarely) checking for errors will indeed show what the problem is. Even more frustrating is that the workflow has been saved including the phantom error. Closing SPD and restarting does not help. In desperation, I deleted steps until there was nothing left except an empty stage, but I could not shake the error. I had to start over.
So now, before I save or publish, I click the "Check for Errors" button in the ribbon.
If I cannot resolve any of the errors, I abandon that iteration of the workflow and make my changes again which although a pain, is much better than a rewrite.
Beware of Sending Long Strings to Workflow History
Sometimes we need to see what is going on within our workflows by writing values to the history log for debugging, informative or other purposes. However, the log accepts up to 255 characters. Anything longer, and the workflow is suspended with this cryptic error message:
Suspend this workflow
Activity in progress
Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP InternalServerError to https://mdigital.sharepoint.com/sites/Digitized_BioP/Test/_api/web/lists(guid'd7055b90-a4b2-4758-a4fc-dfcece0c1969')/Items Correlation Id: efb09adb-123f-475c-81d0-bc3377c5e8fe Instance Id: 0bd5c5e1-6955-4245-9d63-980c80065a50
Invalid text value.
A text field contains invalid data. Please check the value and try again.
Of course, if you are already trying to debug, this can be a bit frustrating until you finally figure out that it is the actual debug statement that is breaking your workflow. Once it is suspended, you must Terminate this workflow or delete the list item to move on.
After doing the above, I finally broke down and used Fiddler to examine HTTP requests, detailed in another blog post in this series.
Updates on Production Workflows
On-premises SPD 2013 workflow developers can take advantage of restoring production backups to a development environment. (If you do this, make sure you cancel any workflows that might generate task reminder emails to real end users, etc.!) You still must repeat all the SPD 2013 Workflow dev work you do for the production side instead of just running a script or deploying new compiled code. Some is copy paste, but there is usually some configuration work required. As noted elsewhere in this series, you can use Remote Desktop to open more than one SPD modal dialog box (e.g., string builder or dictionary variables) in your work environment.
With SharePoint O365, there are some third-party tools which might be used to replicate a production o365 SharePoint for to a production environment, but I've never tried it. Let me know in comments if you have any experience with this.
- Prefix for list items, e.g., [test] in Title field allows you to use code in your workflow and filters on your views.
- In workflow, set a variable e. g., Testing, to [test] if Title contains [test] if you need different functionality, e.g., bypass emails to Leadership group of certain events.
- Filter in lists. Since the character [ is alphabetically before letters and many other characters, you can filter on Title field greater than [TestZ] in your view to remove test data.
- You can also create a personal view for to show your [test] data.
Setting Local String and Dictionary Variables to Null or Blank
- There are two options for String. The first is to Trim a single space and output to your string
Trim (Output to Variable: SomeStringVariable )
- The second option is self-documenting. Create a local String variable called EmptyString, but never set it to anything. Then use
Set Variable: SomeStringVariable to Variable: EmptyString
- Likewise, for Dictionary variables, create a local Dictionary variable called EmptyDictionary and set your Dictionary variable to it.
- Use the String Builder to set EmptyDate to 1/01/0001
Part 1 of a 3-Part Series of Workflows Tips
I have written most of the following posts which should be ready by end of August, 2018. I intend to include the links below:
- General SharePoint Designer 2013 Workflow Tips
- Workflow Task Tips
- Working with REST in SharePoint Workflow