Recently when demonstrating to a customer, one of our most popular workflow content package Document Centric Approval Process, I realised the customer’s environment had several Users on IAS side and the current implementation of the sample UI5 application from our SAP GIthub.com Cloud Workflow Sample Collection, is querying the entire IAS user directory.

In real world, you wanted to allocate selected users as your approvers. So the query need not be “Show me my entire IAS user”.

There are 2 potential solution to this,

  1. Simple Solution – Use IAS SCIM API’s filter option
  2. Recommended Solution – Use a Business Rule to determine departmental approvers or regional approvers and subsequently use it with SCIM API’s filter option. In this way requestors are not aware who are the potential approvers for another departmental process. SAP Business Rules is your tool for enterprise decisions.

First time Readers

In case you are hearing for the first time about this pre-built content package for Workflow, I encourage you to explore this SAP Discovery Center Mission – Automate Document Centric Approval Process

Here are some example use cases you may consider using this workflow sample.

  1. Opening of a Corporate Bank Account
  2. Supplier Contract Review with Finance and Legal
  3. Posting Mass G/L Accounts, Ops team would like to review documents before posting
  4. Project Change Management
  5. Hiring (Job Requisition, Job Description, budget) in HR

Simple Solution – Using Filter option with SCIM API call

The Start UI screen looks like one in the below screenshot.

In the approval steps, a table is shown, where you are able to configure approval steps, approvers, and watchers. The value help selector, are programmed to help you choose your approvers or watchers, the flow of source code in RequestApproval.controller.js is as follows

onValueHelpRequested: function (oEvent) {
    this.selectedValueHelp = oEvent.getSource();
    var sInputField = oEvent.getSource().data().inputCustomData;

    if (sInputField === "ApproverValueHelpType") {
        var oMdlCommon = this.getParentModel("mCommon");
        var oColumns = oMdlCommon.getProperty("/oApproverValueHelpType/cols");
        this.getUsers(oColumns, sInputField);
    } else if (sInputField === "WatcherValueHelpType") {
        var oMdlCommon = this.getParentModel("mCommon");
        var oColumns = oMdlCommon.getProperty("/oWatcherValueHelpType/cols");
        this.getUsers(oColumns, sInputField);
    }
},

and if you explore getUsers function

getUsers: function (oColumns, sInputField) {
    var oThisController = this;

    var oView = oThisController.getView();
    oView.setBusy(true);
    var scimbaseurl = this._getSCIMBaseURL();
    var sUrl = scimbaseurl+"/service/scim/Users/";
    var oSettings = {
        "url": sUrl,
        "method": "GET"
    };
...
// more code
...
}

As you can see the getUsers() function is querying entire SCIM user’s directory.

Any IAS administrator, must be familiar with IAS User Groups. You an explore the below resources to learn more about User Groups in IAS and its usage within filter option in SCIM API calls

So to use filters, I added the below code

getUsers: function (oColumns, sInputField) {
    var oThisController = this;

    var oView = oThisController.getView();
    oView.setBusy(true);
    var scimbaseurl = this._getSCIMBaseURL();

    // modified code to include filters -- start
    var sRole = "workflowApprovers"; // replace your organization specific group name
    var sFilter = 'filter=groups.display eq "' + sRole + '"';

    var sUrl = this._getSCIMBaseURL() + '/service/scim/Users?'+ encodeURIComponent(sFilter);
    // modified code to include filters -- end
    var oSettings = {
        "url": sUrl,
        "method": "GET"
    };

    ...
    // more code
    ...
}

Please use your organization specific appropriate role as sRole variables value.

The current logic of showing the approver or watcher user list, has pagination implemented. You need to amend that portion of code as well to use the filter option as shown below,

getUsersAdd: function (iteration, oColumns, sInputField) {
    var oThisController = this;

    var oView = oThisController.getView();
    oView.setBusy(true);

    var startIndex = (100 * iteration) + 1;
    var scimbaseurl = this._getSCIMBaseURL();
    var sRole = "workflowApprovers"; // replace your organization specific group name
    var sFilter = 'filter=groups.display eq "' + sRole + '"';

    var sUrl = scimbaseurl+ '/service/scim/Users?startIndex=' + startIndex + '&' + encodeURIComponent(sFilter);
    var oSettings = {
        "url": sUrl,
        "method": "GET",
        "async": false
    };

    ...
    // more code
    ...
}

Subsequently,

  • You save the code changes
  • Use mta.yaml to Build MTA Project.
  • Resultant *.mtar archive is saved under mta_archive folder. You can deploy this *.mtar archive.

Try your app again, you should see improved performance improvement when accessing the approvers and watchers

In Part 2 of this blog, I will share a more permanent solution using SAP Business Rules.

For More Information on SAP Process Automation:

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x