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.
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=salesgroupBut 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.
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 = restTo add the destination to your project:
- Go to the Integrations tab.
- Click Add Integration.
- Click BTP Destinations.
- Select the destination.
- Click Install Integration.
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.
To trigger a process deployed to a shared environment, do the following:
- Add a button.
- In the logic canvas for the button, add an HTTP Destination Request, along with any Alert flow functions to show the result or error
- Select the HTTP Destination Request, and set the following in the Properties tab.
Destination sap_process_automation_service_user_access HTTP Method POST Request Body Type json Request Body This 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 Type text
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.
- Go to the Control Tower.
- Click Environments.
- Click your environment.
- Click Triggers.
- Click View next to the trigger for your process.
You will now see the payload for the API for that trigger. This will be the request body.
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.