In JavaScript scripts, the .val() method of Viabl.ai Objects can be used to read or assign it's runtime value.
var g = #Grade.val(); // read the value of the Grade Question into a local variable
if (#Colour.val() == "Red") { // read to check the value of the Colour Question
xpertrule.message("the colour is red");
}
#Grade.val("Director"); // assign the value of Grade Question to "Director"
When used to assign a value to a list object, the .val() method has a second optional Boolean parameter which can be used to supress runtime errors arising from assigning an unknown list value to the list Object. In the following example, if the runtime value for GradeTextInput is not one of the pre-defined list values of the Grade list Object then this assignment will fail without causing a fatal runtime engine error
#Grade.val(#GradeTextInput.val(), true);
It is the responsibility of the developer to ensure that any such failed assignments are handled to prevent any further errors or undesirable behaviour.