Skip to Content
Technical Articles
Author's profile photo Mike Doyle

The easy way to edit workflow context variables

TLDR: SAP Workflow Management doesn’t provide an app to edit workflow context variables, even though this is very useful when resolving issues.  I built my own Fiori app.  Perhaps this functionality could be provided as standard in future?

One of my customers uses SAP Workflow Management (running on SAP Business Technology Platform) extensively for a side-by-side extension app.  The process begins when the requestor completes the ‘Project Creation’ form in a custom UI5 app. Upon approval of the form a number of business partners and commercial projects are created in S/4HANA.

A custom workflow handles the approval process and another handles the creation of master data after approval. Occasionally workflow instances are halted by errors. Once we establish how the error has occurred we make changes to the UI5 app or the CAP (Cloud Application Programming Model) Java app to make sure that same error can’t happen again in future.

Many errors come from user input, such as adding spaces in the wrong places in a tax code. In this case we would improve the validation and formatting in the form to prevent a recurrence, and/or we might change the Java app to handle input in different formats.

The problem is that these changes may be too late for the workflow instance that is now stuck in error.

Often in the workflow we use a script task to prepare data in a context variable ready for it to be passed in an API call.  The service task that follows makes the API call. For example, we might collate the business partner information (including some reads, in our case, of custom business objects in S/4) ahead of the call to create a new partner in S/4HANA.

If these data are erroneous (e.g. we have a space in the wrong place) then when we retry the workflow instance the API will fail once more.  What we need in this scenario is to make an edit to the workflow context, so that when we retry the workflow it can progress to completion.

The Monitor Workflow Instances app doesn’t provide for a context edit, so I decided to build my own Fiori app using SAP UI5.  The purpose of this blog post is to share this concept, at least in its current MVP (minimum viable product) form.  The app uses the RESTful API that is provided with the SAP Workflow Management service (for the Neo & Cloud Foundry environments).  We were already using this service to create new instances of our workflows from the UI5 app.

The app uses the Flexible Column Layout control. First we choose the workflow instance we want to edit:


Step 1, choose workflow instance


The workflow context is rendered in tree form, which can be expanded as required:


Step 2, view context

We then select the context node that we want to edit:


Step 3, select context node to be edited

Note that the save button is enabled when you change the value in the text area.

Of course we need to keep security in mind, as it wouldn’t do to allow the editing of workflow context variables without controls.  First, we should only allow limited access to this app.  Second, we should only assign the standard role WorkflowContextAdmin in production when strictly required and most likely only temporarily.  This should be the case even if there is no such user-friendly UI5 app deployed. NB the workflow log does show who edited the context, but it doesn’t show details of the edits.

Another point to note is that the standard API is not an OData service.  In my UI5 app I used AJAX to make the API calls. The API allows us to query instances, query the context and update the context.

It would be great to hear your comments if you know of a way to edit the context using the standard apps, or if you have developed an app yourself.  Don’t you think this would be an excellent feature to add to the standard SAP Workflow Management suite of apps?

For more background and references see my earlier blog series on SAP Workflow Management

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Susan Keohan
      Susan Keohan

      You're doing great work here, Mike!   Keep it up!


      Author's profile photo Raghuraman Ramakrishnan
      Raghuraman Ramakrishnan

      Hello Mike, thanks for sharing this useful blog. appreciate it.

      Author's profile photo Greg Cariño
      Greg Cariño

      Nice blog Mike!

      Definitely, this is a feature that I think should be added or enabled as part of the existing Retry mechanism.

      I faced some situations where we had to ask different users and approvers to re-submit and and re-process requests just because of a workflow instance that was stuck due to bad data.

      Author's profile photo Zack Cain
      Zack Cain

      Hey Mike,


      This looks fantastic, are you going to make this available to the public? As this would be very useful!

      Author's profile photo Mike Doyle
      Mike Doyle
      Blog Post Author

      Hi Zack, thanks for your feedback.  I developed this for a client and, whilst they were happy for me to share the concept, I'm not able to share the code itself.  My hope is that SAP will provide a standard app to do this

      Author's profile photo Thorsten Klingbeil
      Thorsten Klingbeil

      Coooooool Solution, Mike - thanks for sharing! 😎

      Do I get it right, that it is a UI5 freestyle app with REST-Service (JSON-Model based)?

      We plan to build the same solution with Fiori Elements and are looking for a fitting OData-Service in the API Business hub - but couldn't find anything, so far 😒



      Author's profile photo Mike Doyle
      Mike Doyle
      Blog Post Author

      That's right, it's a freestyle app.  SAP have provided an API we can use but not an OData service, so I think it would be very challenging to get it to work with Elements.  What I would like is for SAP to provided a standard UI5 app too.