Action Syntax examples
Last updated
Last updated
This document provides examples of the Action Syntax used to define actions in Form Builder.
The Nobel Prize organization exposes a REST API. We would like to create a form that queries that API to return the 2023 Nobel Prize winners, and show these details in a table.
To do this, we start by creating a simple form with a nested repetition:
a repeated section for the Nobel Prizes
a nested repeated grid for the laureates
Here is how the form looks like in Form Builder:
We then also create an HTTP Service endpoint:
It points to the following API endpoint:
This returns data in JSON format (with ...
to indicate omitted parts):
Form Runner operates on an XML view of JSON data so that you can use XPath formulas. You can see it directly in the "XML Response Body" of the HTTP Service Editor. Here is what that view looks like:
Finally, we write, using the Form Builder's Action Syntax, an action that:
runs upon form load
calls the get-nobel-prizes
service
clears the prizes
repeat
iterates over the Nobel Prizes (/*/nobelPrizes/_
), and for each entry
adds iterations to the prizes
repeat
sets values in the controls year
and category
from the awardYear
and category/en
fields in the data
clears the laureates
repeat
iterates over the laureates (laureates/_
), and for each entry
adds iterations to the laureates
repeat
sets values in the controls known-name
and motivation
from the knownName
and motivation/en
fields in the data
There is a nested iteration due to the nested repeats. here is what the complete listener and action look like:
When you test or run the deployed form, you see the Nobel Prize winners for 2023:
Blog post: Making sense of Form Runner Actions