Script triggered by an Event

Prerequisites

Procedure

The goal is to trigger a script through an app. For learning purposes, the following tutorial will be simple. In this example, this event will be triggered each time the user updates the sap.m.TextArea through the elements liveChange event. These changes will displayed through the System Logs via the script that will be set up.

Step 1. Set up script and the Event

  • For the script:

    1. Create a new script

    2. Add the below code. Since these changes are reflected in the System Logs, the code will be simple:

log.info(payload);  //payload will be the data sent to the script
complete();
  • For the Event:

    1. Open Events, create a new Event and give it a meaningful name

    2. Choose Script at Event Action

    3. Select your script at Script

Step 2. Configure the EventTrigger on an app

  1. Open an app and from the component library, search for EventTrigger and drop it in Resources

    This a Neptune build-in component called neptune.events.Trigger
  2. Rename the EventTrigger and at event under Properties, select the Event that you defined. In this case it is named ReflectChanges

    events create script element
  3. At the liveChange of the sap.m.TextArea paste the following:

const newText = this.getValue();
triggerReflectChanges({text: newText});

Step 3. Test the changes

  • At the app:

    events create script app text
  • At System Logs

    events create script logs

Result

You know have a basic an understanding of how Events and the Redis Server function on Neptune DXP - Open Edition