Update app data using accessors
In the following example, app data and accessors will be used to display and update data.
First, in the app data level, add a new data field named
test_number
, whose Data type is number, Storage type is "In Memory" and Default Data Value is 1.

Drag a text element to the canvas and enter
${#app.test_number}
in text field. In the app view, the text will display the value of test_number
.
Drag a button onto the page below the text. Then, open the interaction panel to add an action: App -> Set app data after the event 'click button.' Next, click on the f(x) icon to edit the transformer.
Hint: the transformer uses JavaScript.
For more information, refer to the related page: Interactions.
Using accessor, edit transformer code, remember to click the update button to save the change. Code for reference:
function transformer(payload, context) {
const test_number = context.getData("#app.test_number");
const updated_test_number = (test_number + 1) % 3;
const parameters = {"field":"test_number","value":updated_test_number};
return parameters;
}


Last modified 2d ago