Defensive Workflow Design Part 5 - Batching

  • 6 March 2017
  • 3 replies
  • 248 views

Userlevel 7
Badge +10

Planning Ahead

When designing a workflow it is often assumed that the actions will be processed in the exact order they are shown in the designer. While true most of the time, if your workflow is utilizing any batched actions (see below), the actions do not always execute synchronously.

 

What is a batched action?

A batched action is any action that makes a change to a SharePoint environment. These actions are added to a batch and processed together.

 

How are batched actions handled?

SharePoint Workflow Infrastructure processes activities synchronously until it reaches a point where the workflow is blocked (Task, Pause, etc). Only at this point will SharePoint commit batched actions. Processing changes to SharePoint in batches has several advantages:

  • Processing changes in a single SQL transaction is less resource intensive than processing every change as it occurs in a workflow.

  • When SharePoint encounters an exception while executing a workflow action, it will roll all changes back to the last commit (Native SharePoint Workflow Actions only). This makes the infrastructure more durable.

 

Performance

While adding a commit action after every batched action will ensure things are processed in the intended order, it is not optimal. It is advised to commit the batch after a group of actions without dependencies on one another are processed.

 

Example: Several field update actions that do not rely on one another for the values that are being updated.

If a series of batched actions have dependencies on one another, a commit should be added. This will ensure that each batched action is processed before actions that depend on the values are processed.

 

Example: A field update is processed that affects a filter parameter used for a list query.

 

Design Considerations

  • Batched actions have the tendency to behave asynchronously in that SharePoint does not wait for them to process completely before moving on to the next action in the workflow (unless committed).

  • Commit batched actions if the values they affect are used later in the workflow. Not committing batched actions can lead to null reference exceptions in a workflow or other unexpected errors.

  • If a batched action does not have any dependencies, it can be allowed to process without a pause or commit.

 

Additional Reading

 

More Information

 


3 replies

Userlevel 5
Badge +14

does sharepoint manages (maximum) batch size anyhow?

ie. whether if amount of changes is about to reach some limit, it applies or commits the batch without waiting for next 'block' action? or the 'block' actions are really only points when batched are committed?

I ask since it is usually seen that if batched changes are made within a loop, then workflow fails if accumulated batch size exceed some unclear limit.

Badge +6

The Additional Reading link points to an article from WSS 3.0. Is that still relevant to Nintex WF Operations? 

Userlevel 7
Badge +10

Yes, it still applies.

Get Outlook for Android<https://aka.ms/ghei36>

Reply