setProperty - Set the value of a variable
Example
In the following simple example, the use of setProperty is shown. Practically, this function can be used to jump between different pages of a form, such as shown here shown here.
setProperty.json
{
"$schema": "http://bpc.virtimo.net/forms/1/schema",
"metaData": {
"id": 0,
"version": 0
},
"components": [
{
"type": "container",
"label": "setProperty Example",
"components": [
{
"type": "html",
"value": "'<p>Current value of variable: ' + /data/someValue + '</p> New value of variable after click on subtract: ' + (/data/someValue - /data/subtractValue)"
},
{
"type": "numberfield",
"label": "Changeable value of variable",
"value": "/data/someValue"
},
{
"type": "numberfield",
"label": "Input value which is subtracted from above variable if subtract button is clicked",
"value": "/data/subtractValue"
},
{
"type": "button",
"label": "Increment",
"action": "setProperty",
"target": "/data/someValue",
"value": "/data/someValue +1"
},
{
"type": "button",
"label": "Subtract",
"action": "setProperty",
"target": "/data/someValue",
"value": "/data/someValue - /data/subtractValue"
},
{
"type": "button",
"label": "Set to 1",
"action": "setProperty",
"target": "/data/someValue",
"value": 1
}
]
}
],
"configuration": {
},
"state": {
"data": {
"someValue": 5,
"subtractValue": 3,
"readOnlyVariable": true
}
}
}
Embedded preview
Keywords: