Skip to Content

10 - Call 3rd-Party System and Wait for Callback

Add a "Wait for an API Call" to integrate an external system by using an action to call the system and then waiting for the system to trigger resumption of the process instance.
You will learn
  • How to pause process instance with “Wait for an API Call”
  • How to call trigger to resume process instance
thecodesterDaniel WroblewskiMay 21, 2025
Created by
thecodester
March 11, 2025
Contributors
ajmaradiaga
thecodester

Prerequisites

  • Step 1

    Remember, our action will just describe the type of service we want to access, but we need to create a destination to indicate the actual backend service to call.

    1. Download the destination template.

      Click Destination template, and then click the download button.

      Download destination
    2. Go to the SAP BTP cockpit for your subaccount.

      You can always return to your trial account cockpit by going to https://account.hanatrial.ondemand.com/ and then opening your subaccount.

      Click Connectivity > Destinations.

      Import destination

      Click Import Destination, and select the file you downloaded.

      Import destination
    3. Click Save.

    4. Click Check Connection, and you should get a 200 status code.

      Test destination
  • Step 2

    You created a destination, but you must let SAP Build Process Automation know that you want to allow it to be used in deployed processes.

    1. In the main SAP Build page, click Control Tower.

    2. Click Destinations.

      Add destination to Control Tower
    3. Click Add.

      Click Add

      Select the AccessProService destination.

      Select destination

      Click Next.

      Keep All Environments, and click Add Destination.

      Destination added

    The destination should now appear in the list of destinations that can be used with your processes.

    Destination added
  • Step 3
    1. In the SAP Build menu, click Actions.

      Open Actions
    2. Click Create.

      Create

      Select OData Destinations.

      Odata Destinations

      Select AccessProService.

      AccessProService
    3. You will now see a list of all the entities and all the API calls you can make, only for your information.

      Available calls

      Click Next.

    4. Name the action as follows:

      Field Value
      Name Access Pro Service
      Description A 3rd-party service for managing the creation of employee/visitor badges.
      Name action

      Click Create.

      You will now see the operations available for this service, and you will need to decide which ones to expose (to “your” developers).

    5. Select the POST /Badges call, since you will want to create a new badge request during your process.

      Select API

      Click Add.

      You now get the action where you can modify the inputs and outputs, or add additional API calls to this action. We will keep the inputs and outputs as is.

    6. Under Inputs, select ID and click Remove.

      The CAP service will generate an ID automatically, so we do not want to be forced to supply that field.

      Remove field

      Click Save.

      Save action
    7. Click Release, then click Release to confirm..

      Release action

      Click Publish, and then click Publish to confirm.

      Publish action
  • Step 4

    We will want the 3rd-party system to call our process back, and we need to supply to it the process instance ID. So first we must store the value.

    1. Go back into your process, and make sure you have the Editable version open.

      With nothing selected (just click in an open space), open the side panel.

      Under Variables, and then under Custom Variables, click Configure.

      Configure variable
    2. Click Add Variable.

      Set the name to instanceID.

      The identifier is automatically generated and the type is automatically String.

      Click Apply.

      Add variable
    3. Above the notification step, add a script task.

      New step
    4. Set the name to Get instance ID.

      Rename
    5. Open the editor.

      Add the following line to the editor.

      JavaScript
      Copy
      $.context.custom.instanceid = $.info.workflowInstanceId
      
      Create script

      Click Apply.

    6. Click Save (upper right).

  • Step 5
    1. Under the script task, click the plus sign, +, and add an action.

      Add action step
    2. Click Browse All Actions.

      Browse All Actions

      Select the Add new entity to Badges (as part of Access Pro Service project), and click Add.

      Add action
    3. In the side panel, create a destination variable.

      Click inside the Destination Variable field, and click Create Destination Variable.

      Destination variable

      Name the variable AccessProDest, and click Create.

      New variable
    4. Under inputs, bind the input fields:

      Field Value
      businesspartnerId Process Inputs > data > BusinessPartner
      communityId Process Inputs > data > YY1_SAPCommunityDisplayName
      firstname Process Inputs > data > FirstName
      lastname Process Inputs > data > LastName
      processInstanceId Custom Variables > instanceID
      status Approved
    5. Click Save.

  • Step 6
    1. Under the action, click the plus sign, +.

      Add step
    2. Click Controls and Events.

      Controls and Events

      Scoll down and select Wait for an API Call.

      Wait for an API Call

      Click Create an API Call.

      Create an API Call
    3. Call the API trigger AccessProCallback, and click Create.

      Wait Trigger
    4. With the new step selected, open the side panel.

      Select the Outputs tab, and click Configure.

      Configure wait
    5. Click Add Ouput.

      Set the name to badgeId, and click Apply.

      Add output
    6. Click Save.

  • Step 7

    Our 3rd-party system will call back to our process instance, and send a badge number. Let’s add that to the notification form.

    1. Click the 3 dots next to your notification form, and select Open Editor.

      Open form
    2. Add a Paragraph and set its text to:

      Text
      Copy
      Your badge number is:
      

      Add a Text field. Call it Badge Number and set to read only.

      New form fields

      Click Save.

    3. Back in the process, with your form selected, open the side panel.

      Under Inputs, bind the badgeId from the Wait for Badge System step to the new form field.

      Bind field
    4. Click Save.

  • Step 8

    In order to call an SAP Build Process Automation trigger – either a standard trigger or a wait trigger – you must send an API key with adequate permissions.

    1. Go to the Control Tower, and click Environments.

      Environments

      Select the Public environment.

      Public
    2. In the API Keys tab, click Add API Key.

      Add key
    3. Call the key AccessProCallbackAPIKey, and click Next.

      BadgeKey

      Enable the following scopes:

      • trigger_read
      • trigger_execute

      Click Next.

      Add scopes

      On the Review page, click Add.

      Add scopes
    4. A key will be generated.

      IMPORTANT: Make sure to copy and save it in a safe place.

      Add scopes
  • Step 9
    1. Click Release.

      Release

      Confirm by clicking Release.

    2. Click Show project version (upper left).

      This will take you to the released version of your project, so you can deploy it.

      Released version
    3. Click Deploy.

      Deploy

      Select the Public environment.

      Select Upgrade.

      Note that it will show you that a new trigger will be created for the Wait for an API Call step.

      New trigger
    4. Click Deploy.

      You will now have a new destination to select, since you created a destination variable for the action to create a new badge request.

      This is in addition to the one you selected in previous deployments for the S/4HANA backend.

      Destinations

      Select the AccessProService destination, and make sure the S4HANA_Badges destination is selected.

    5. Click Deploy.

    6. After deploying, go to the Control Tower > Environments, and go to the Public environment.

      Check triggers

      Click Triggers, and you will see the trigger created for the Wait for an API Call. The trigger is called AccessProCallback.

      Wait trigger

      Click View

      View trigger

      You will see the connection details for the 3rd party system to call our process instances to resume them.

      Copy the URL and put it in a safe place, where you put your API key. You will need these when we use the 3rd-party system.

      IMPORTANT: Your URL will be different than the screenshot.

      Trigger URL
  • Step 10

    Things to Ponder

    How did you get the process instance ID to pass to the 3rd-party system?

    What other details about your process can you get this way?

    What other integrations could you imagine with the “Wait for an API Call”?

    What other scopes can you specify for an API key?

Back to top