Script Example 3: Use Table onAfterDataEntryProcess Event

As a story developer, you can write scripts for a table's onAfterDataEntryProcess event to let story viewers run data actions with its data changes.

Prerequisites

  • You've created a story and added the following widgets:
    • A table Table_1, which uses a planning model

    • A button Button_1

  • You've created a data action DataAction_1 with the following configurations:

    • A copy step, which copies values of budget version from 2024 to 2025

    • A parameter EntityParam, with dynamic input on dimension Entity

Context

You'd like to write scripts to let story viewers run DataAction_1 when data on Table_1 is changed via data entry, copy and paste, or submitData() API by clicking a Button_1.

Procedure

  1. In the Scripting section of Outline panel, add a Data Actions technical object.
  2. In the Data Action Configuration panel, select DataAction_1 from the dropdown list.
  3. In the Scripting section of Outline panel, add a script variable.
  4. In the Script Variable panel, configure the following:
    1. Enter a name, changedEntities.
    2. Select string as type.
    3. Set the variable as an array.
  5. Add a list box ListBox_1 to your story. Keep the default widget configurations.

    You'd like the list box to display all changed entities.

  6. In the Outline panel, hover over Table_1, and select Start of the navigation pathEdit Scripts Next navigation step onAfterDataEntryProcessEnd of the navigation path.
  7. In the script editor, enter the following script for the table's onAfterDataEntryProcess event:
  8. Hover over Button_1 in the Outline panel, and select Edit ScriptsStart of the navigation path Next navigation step End of the navigation pathonClick.
  9. In the script editor, enter the following script for the button's onClick event:
  10. View your story.

Results

In view mode, when you change values of entities of budget version in 2024 and then click the button, the list box shows all the changes, and the values are copied to corresponding cells in 2025.