Using the business scenario for this course, we will take you through extending a data action button for a specific use case. However, there may be other reasons why you want to create a custom button in a story.
Why would you extend a button with scripting?
Data action buttons can be extended to:
- Run multiple data actions. Buttons can be extended to run multiple data actions while data action triggers can only run one data action. Extending a data action button means that planners have fewer buttons to push and the data actions always run in the proper sequence.
- Automatically trigger a data action. Buttons can be extended with dependencies to automatically run a second data action when the first data action runs successfully.
- Display custom dialogs and popup messages. Buttons can be extended to provide the user with personalized messages and dialogs while data action triggers only display the built-in system dialogs.
- Select the context of another widget (such as a data table) and automatically apply it to your data action. Buttons can be extended to eliminate the need for a planner to manually provide values in a prompt dialog.
Buttons can be used for more than just data actions. Buttons can also be extended to:
- Add buttons for design-time settings. For example, if a planner doesn’t have edit access to a story, they can press a button to change a property such as setting a table as read only.
- Display a list of versions for a data table.
- Allow easy access to toolbar options such as refresh and revert, making it easier for planners because they no longer need to search for options in the toolbar.
Add Code to a Planning Story Element
There are three ways to add scripting to a story in the script editor:
- Use the autocomplete by selecting CRTL + SPACE and starting to type what you're looking to add.
- Type the code directly into the script editor.
- Paste the code from a document where you’ve saved it.