Technology Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 

After this post was written, with the help of the wonderful community, we came up with a different, and in most ways, better solution for this issue. See https://community.sap.com/t5/technology-blog-posts-by-sap/triggering-process-in-shared-environment-f....

But what's written in this blog is still valuable, because it will show you how to use the relatively new flow function HTTP Destination Request, which lets you easily and still with a good amount of control call APIs using destinations.

434322

rule.png

Unfortunately, the Processes flow functions to trigger processes from SAP Build Apps (for now) do not work for shared environments. And since the public environment is deprecated, that means they essentially no longer work at all.  Hopefully this will be modified soon.

In the meantime, here's how to work around that issue.

The Issue

I am not sure but I assume the issue is that when you make an API call to trigger a process in a shared environment, you must send the environment id as a query parameter.

/workflow/rest/v1/workflow-instances?environmentId=salesgroup

But the flow functions do not have an input for the environment, so they automatically try to trigger a process in the public (default) environment.

By the way, the identifier for an environment can be found when you open the environment in the Control Tower.

Dan_Wroblewski_0-1754292357919.png

The Workaround

The good news is SAP Build Apps recently added a new flow function called HTTP Destination Request that lets us create a customized HTTP request but using a destination. That is we get the control we get from the HTTP Request flow function but with the ability to connect through a destination.

As a prerequisite you need to have a destination called sap_process_automation_service_user_access to the SAP Build Process Automation service, the same as if you wanted to use the Processes flow functions. This is described in the Processes documentation.

You will need to add the destination properties so that it appears in your SAP Build Apps project:

BuildApps.Enabled = true
BuildApps.ApiType = rest

Dan_Wroblewski_1-1754295940486.png

To add the destination to your project:

  1. Go to the Integrations tab.
  2. Click Add Integration.                                                         Dan_Wroblewski_5-1754297243220.png
  3.  Click BTP Destinations.
  4. Select the destination.Dan_Wroblewski_7-1754297563900.png
  5. Click Install Integration.                      Dan_Wroblewski_8-1754297653486.png

If you go back to the Integrations tab main screen, you'll see the destination. That's all you need to do to add the destination to the project and make it available to your HTTP Destination Request flow function.

Dan_Wroblewski_9-1754297767359.png

rule.png

To trigger a process deployed to a shared environment, do the following:

  1. Add a button.
  2. In the logic canvas for the button, add an HTTP Destination Request, along with any Alert flow functions to show the result or errorDan_Wroblewski_2-1754296310420.png
  3. Select the HTTP Destination Request, and set the following in the Properties tab.
    Destinationsap_process_automation_service_user_access
    HTTP MethodPOST
    Request Body Typejson
    Request BodyThis depends on the proper request body for your process. More on this below.
    Path
    /workflow/rest/v1/workflow-instances?environmentId=<environment ID>

    Replace the placeholder with the identifier for your environment.

    Response Typetext

    Dan_Wroblewski_3-1754296454316.png   Dan_Wroblewski_4-1754296464448.png

The flow function has 3 outputs.

  • The first if the call is successful and returns 2XX status code.
  • The second if the call is successfully transmitted and a response is received but returns a 4XX or 5XX status code.
  • The third if the call is unsuccessful and no response is received.  

Request Body

The request body is determined by checking the trigger for the process.

  1. Go to the Control Tower.
  2. Click Environments.
  3. Click your environment.
  4. Click Triggers.
  5. Click View next to the trigger for your process.

Dan_Wroblewski_10-1754299263361.png

You will now see the payload for the API for that trigger. This will be the request body.

Dan_Wroblewski_12-1754299399680.png

Note that you cannot copy from the box with the payload. You will have to use the copy button to copy the entire payload. Note also you can see the URL for the API, including the environmentId parameter you must pass.

The Upshot

The method above is pretty straight-forward and has the advantage of teaching you what is happening behind the scenes and how the SAP Build Process Automation APIs work. But I'll admit you lose the ease of use of the flow functions, and also the ability to create variables from the input and output schema of your processes.

 

8 Comments
Labels in this area