Webhook Success Key #4: Carefully Manage SharePoint State

John E. Huschka, January 25, 2018

Target Audience:
SharePoint Developer
Technology:

Azure Functions — Internet cloud based custom code for SharePoint and Office 365.

SharePoint Webhooks — Connections that allow us to attach custom code to SharePoint that is called when events occur.

This post is part of our blog series and demonstration code on achieving webhook success.

We frequently see two major uses of event driven processing in SharePoint:

Data Synchronization: Essentially, when you need to perform calculations on your data and/or move/copy data from one place to another.

Process Automation (workflow): When new data or changes in existing data require action to further a business process—providing information to a person or automated system, for example.

If your webhook is doing data synchronization, it probably has no state considerations. For example, if your webhook needs to concatenate names to create a full name, there is no state management.

First Name
Middle Name
Last Name
Full Name
John
Kevin
Jones
(empty)
Names above are updated. Webhook runs, updating full name.
John Kevin Jones

Here, if the webhook fires every time there is a change, it will simply re-update the full name.

State management is critical however, if you are doing SharePoint business process automation, such as payment processing.

As an example, let’s assume that we have a SharePoint list for which a webhook makes payments. A new item (“second item”) is entered into the list:

New Payment Item

The webhook runs, making a payment and updating the item’s Payment Status and Webhook Processed date:

Processed Payment Item

It is critical that the payment not be re-sent, no matter how many times the webhook is fired. Therefore, the QueueTransactionProcessor checks the Webhook Processed date when it runs on subsequent webhook calls to avoid making a re-payment. The QueueTransactionProcessor is using the Webhook Processed date to maintain the state of the payment.

Note that when the webhook handler updates Payment Status and Webhook Processed date columns, the webhook will re-fire. Aside from the extra processing caused by the re-fire, this should cause no issues as long as state is being properly maintained and checked by the webhook handler.


 


We at Collaboration Foundry are experts in SharePoint and Office 365. If you need assistance, we can help. Contact us.
Also, don't forget to take a look at our blog for more helpful tips and techniques.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHAThis question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
3 + 9 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.