SharePoint 2013 Designer and Workflow Tips, Tricks & Traps

Today, I want to share my experience working with SharePoint Workflows via SharePoint Designer. Sometimes it may be very painful, but I hope after reading this article you will not step on a rake.

Dictionary variables

Do not log a dictionary variable the Log History. This is a very common issue, your workflow just becomes stuck in the started state with the following error:

  1. Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP InternalServerError to https://plumsail.sharepoint.com/sites/Test/_api/web/lists(guid'04dc3f6a-968e-4ce0-a7cc-10949dfb15db')/Items Correlation Id: f54b9d7e-5242-1408-b066-5239a7b01c0a Instance Id: 967e7b1b-96cd-4fbf-b6d4-4df91199831b  
Invalid text value.

A text field contains invalid data. Please check the value and try again. Retry now.

It occurs because your data is too big. This workflow action can display a limited number of symbols. Otherwise that error occurs. As a workaround, you can use Send E-Mail with Attachments (SMTP) instead of log to history.

If you send a dictionary by email then you can receive it's structure in JSON format. It is very helpful to understand the structure.

Using Get an Item from Dictionary

Be careful using Get an Item from Dictionary. Usually you need to get an item from an array and you use a "Get an Item from Dictionary" workflow action like this:

However, please be careful because if you have extra whitespace in the path, your workflow can be stuck in a suspended status with the following error:
  1. RequestorId: 261892b4-cf71-e580-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.FormatException: The DynamicValue property '(0) ' was incorrectly formatted. at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.Parse(String segmentText, String fullPathName) at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.Create(String segment, PathSegment next, String path) at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.Create(String path) at Microsoft.Activities.GetDynamicValueProperty`1.Execute(CodeActivityContext context) at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) Exception from activity GetDynamicValueProperty<DynamicValue> Sequence Microsoft.SharePoint.WorkflowServices.Activities.LoopNTimes Test WF Sequence Flowchart Sequence GetGroupMembers.WorkflowXaml_a9b1b4bd_9995_41a1_9da2_f8f57ce75c54  

SharePoint Designer Cache Errors

SharePoint Designer Cache Errors can occur. The following error is very common when you work with SharePoint Designer:

“Failed to Load this workflow. To correct this problem, restart SharePoint Designer.”



Figure 1: "Failed to Load this workflow.." error

To resolve it, you need to clear the SharePoint Designer cache.

And here are the commands for the command line to do it:

  1. rmdir "%LOCALAPPDATA%\Microsoft\WebsiteCache\" /s /q  
  2. rmdir "%APPDATA%\Microsoft\SharePoint Designer\ProxyAssemblyCache\" /s /q  

Create self-documented workflow using stages

You need to create a self-documented workflow using stages. You should understand how fast you can forget something that you did some time ago, when you are using a workflow please try to use the correct stage names and divide your workflow into small pieces of actions (like procedures in programming languages). In addition, you can use an "Add a Comment" workflow action to leave additional comments in your workflow.

As an example of the self-documented workflow I can provide a notification workflow that I was described in my previous article.

Use Dynamic Value Evaluator to check your expression

Use a Dynamic Value Evaluator to check your expression. It is useful when you use "Get an Item from Dictionary", you can easily check your expression using Dynamic Value Evaluator. For example you have some data in your dictionary and want to build a path to retrieve it. This is a tool that can help you to do it. Just past the JSON structure of your dictionary into a TextBox and write your path, then click "Run". It will show what result you can expect.



Figure 2: Dynamic Value Evaluator Dynamic



Figure 3: Value Evaluator SharePoint Designer

Lookup User Name/Login/Email by ID

Indeed this is one of my favorite features you can use any string variable with integer value and lookup user data by ID. The following example returns the correct display name of the user by specific ID.

You just have an ID, but retrieve the display name.



Figure 4: Lookup user name by ID

Get Date in required format

You can use an out-of-the-box method as in the following figure:



Figure 5: SharePoint Designer Format Date Time

Additionally you can use the free custom action "Format Date" from Plumsail Workflow Actions Pack.

Use Requestb.in to check your query

When you use "Call HTTP Web Service" you need to see how your request looks. RequestBin service can help you with that, it just logs all queries and shows them to you.



Figure 6: Debug CALL HTTP Web Service workflow action

Use App Step to get access

Use an App Step to get access. This is a hard-to-use feature, but in some situations, it is the only way to get the required data. Moreover, you can use an app-step to get data (for example via REST request) from another web. To use it you need to activate the feature that is called "Workflows can use app permissions". Then, you need to manually grant necessary permissions to your workflow via the AppInv.aspx page. You can find more info on MSDN.

Conclusion

In this article, I have tried to collect the most interesting notes that I hope can save a huge amount of your time when creating your workflows. SharePoint 2013 workflows are quite flexible and allow you to use complex objects and loops, but sometimes they just hit you in the stomach with some non-obvious errors.

The original article is available on our blog.

Up Next
    Ebook Download
    View all
    Learn
    View all