Technical Articles
Setting up Document Centric Approval Process in BTP trial account
Introduction
Document Centric Approval Process is one of the Live Process Packages that SAP Workflow Management provides. Live Process Packages contain pre-built:
- process templates
- workflows
- user interfaces
- decision logic
- visibility scenarios
— Stephan Schluchter, Live Process Content Packages – your accelerators for Digital Process Automation
With Document Centric Approval Process, you can add one or more approvers as you wish, attach documents, and approvers will receive E-mail notifications.
As these functionalities are likely to be required in many business scenarios, I thought this package would be a good starting point for understanding SAP Workflow Management’s capabilities, and how I can integrate other BTP services such as SAP Document Management Service into my workflow.
In this blog, I’m going to share how I have set up Document Centric Approval Process in my BTP trial account.
Challenges
You can find setup and user guide in SAP API Business Hub. You can go through most of the steps without problem in your trial account.
However, there were a few challenges to me:
- Identity Authentication is not available in trial account
- Sending E-mails from the workflow failed at the first time (I used my Gmail account for sending mails)
Down below, I will show you the steps (and links) to configure Document Centric Approval Process and how I solved above problems.
Configuration Steps
1. Configure Workflow Email Destination
Configure a destination bpmworkflowruntime_mail as below. Here I used my Gmail account.
Link: Configure the Workflow Service Mail Destination
Workflow Email Destination
2. Configure Document Management Service Repository
Create a service instance for Document Management Service, Integration Option.
Next create a service key and a repository for storing workflow attachments.
Necessary information for creating a repository can be found in the service key.
Document Management Service Key
After sending a POST request, you will receive response like below. Note down “id” as this is required in the next step.
Repository ID
Link1: Creating a Service Instance
Link2: Connect to Document Management Service, Repository Option Using API
3. Configure Document Management Service Destination
Configure destination bpmworkflowruntime_attachments as below.
Again, you can find necessary information in the service key created in the previous step.
Attachments Destination
URL will be like : https://api-sdm-di.cfapps.eu10.hana.ondemand.com/browser/b158ad7c-ea38-4fca-8308-5c04fbbb678d/root/
, where b158ad7c-ea38-4fca-8308-5c04fbbb678d is the Repository ID you got in the previous step.
4. Configure Identity Authentication Service Destination
In a productive account you would configure Identity Authentication service destination as below.
Identity Authentication Service Destination
This destination is used by the workflow Start UI for two purposes:
- To obtain requestor’s information such as First Name, Last Name, Email Address and User ID
- To get possible approvers in the value help
Requestor Info
Approvers Value Help
In the trial account Identity Authentication is not available so I created a simple Node.js app that mocks response from Identity Authentication. You can find the code in GitHub.
After deploying the mock app to BTP, you can configure the destination SCIM as below.
SCIM Destination
5. Deploy Custom UIs and Workflow module
Download the zip file from GitHub and import it into SAP Business Application Studio. The project structure looks like below. You can just build and deploy the content.
6. Add Workflow start UI in Fiori Launchpad Site
Go to SAP Launchpad site manager and add the Workflow start UI to the Launchpad.
As a result, you will see Document Centric Request tile in your Launchpad.
Document Centric Request Tile
Run and Troubleshoot
After completing above steps, I was able to open the Start UI, add approvers from the value help and attach files. However, I still had below issues.
Access to workflowruntime failed
*Update*
After creating a destination pointing to workflow service instance, the following error has been resolved.
When I pressed “Request Approval” button, I received the following error. xsrf-token fetch request was failing with internal server error.
Workflow Start Error
I have posted a question to SAP Community, but the issue hasn’t resolved yet.
BTP Workflow: Getting xsrf-token fails (403 Forbidden)
As a workaround, I have created a destination pointing workflow_rest_url and referenced the destination in xs-app.json.
xs-app.json (before)
{
"welcomeFile": "/index.html",
"authenticationMethod": "none",
"logout": {
"logoutEndpoint": "/do/logout"
},
"routes": [
...
{
"source": "^/workflowruntime/(.*)$",
"target": "/$1",
"service": "com.sap.bpm.workflow",
"endpoint": "workflow_rest_url",
"authenticationType": "xsuaa"
},
...
]
}
xs-app.json (after)
{
"welcomeFile": "/index.html",
"authenticationMethod": "none",
"logout": {
"logoutEndpoint": "/do/logout"
},
"routes": [
...
{
"source": "^/workflowruntime/(.*)$",
"target": "/$1",
"destination": "WorkflowRESTAPI",
"authenticationType": "xsuaa",
"cacheControl": "no-cache, no-store, must-revalidate"
},
...
]
}
Workflow Rest URL Destination
As a result, I was able to start the workflow.
If somebody has any idea why a route pointing to the service “com.sap.bpm.workflow” doesn’t work, please comment down below.
“Notify Approver” failed
The first step in the workflow is to notify the approver via Email. However, in the workflow execution log, I saw below error.
Notify Approver failed
This had something to do with Google security settings. Finally I found this page and followed Troubleshoot problems section.
As I hadn’t activated 2-step verification in my Google account, all I needed to do was to:
- allow less secure apps to access your account
- and visit https://www.google.com/accounts/DisplayUnlockCaptcha
Finally, notification is sent out via Gmail.
Gmail Inbox
Conclusion
In this blog, I introduced the settings for Document Centric Approval Process in BTP trial account and some trouble shooting tips (some of which is still not resolved).
Once it’s started to work, you can find how certain processes (like multiple approval steps, or adding attachments) is realized and apply them to your own scenarios.
References
- Live Process Content Packages – your accelerators for Digital Process Automation by Stephan Schluchter
- Document Centric Approvals using SAP Cloud Platform Workflow Management by Venugopal Chembrakalathil
- SAP API Business Hub – Document Centric Approval Process
- SCIM mock service (Git)
Hi, Yasutake
Greate blog!
But when I tried to deploy the mtar project . It ends with error :
oundry.multiapps.controller.persistence.services.FileStorageException: com.sap.cloud.lm.sl.xs2.content.client.ContentDeployerException: Operation 'Upload File' to the URL 'https://html5-apps-repo-dt.cfapps.eu10.hana.ondemand.com/v2/files/upload' failed. Remote server responded with HTTP status code 500, error message: 'Upload application content failed { CODE: '1001' } validation error: Could not find applications in the request.', error type 'Bad Request' .
Best regards!
Jacky Liu
Hi, Yasutake
The error is caused by the zip file not generated when we build the MTA project .
Best regards!
Jacky Liu
hi, Mio Yasutake,
At last I resolved all the issues .
Need to change in mta.yaml the commands from npm run build to npm run build_old . Need to update the workflow instance name in mta.yaml . Then everything would be ok .
Best regards!
Jacky Liu