Skip to content Skip to footer

Handle widget values using form script

setWidgetValue():
You can use this function to set the value of the widget. Works in asset workflow & action workflow.
Once you open the form then the value you have mentioned in the form script will be set to the specified widget as we have written the form script with the “on_load” function.

function on_load(ws){
ws.setWidgetValue("Textbox","test");
ws.setWidgetValue("Choice_List",'[\"Choice 2\"]');
ws.setWidgetValue("Date_Time","16th November 2021");
ws.setWidgetValue("Timestamp","2021-11-17 10:40:03 ");
ws.setWidgetValue("Toggle","1");
ws.reloadUICells(["Textbox"]);
ws.reloadUICells(["Choice_List"]);
ws.reloadUICells(["Date_Time"]);
ws.reloadUICells(["Timestamp"]);
ws.reloadUICells(["Toggle"]);
}

getWidgetValue():
You can use this function to get the value of the widget. Works in asset form & action form.

function getvalue(ws)
{
var value =  JSON.parse(ws.getWidgetValue("Choice_List_3"));
ws.setWidgetValue("Textbox_9",value[0]);
ws.reloadUICell("Textbox_9");
}

Widget Property Changes:
The function name in the form script is “getvalue()”. So you have to write the function name as “getvalue” in the “on value change” property of the source widget. A source widget is something from which you are getting a value.

Was This Article Helpful?

0
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *

Close Bitnami banner
Bitnami