Users are now able to check and uncheck multiselect fields using Lua scripting in Form Templates.
Pre-requisites:
The Agency uses Lua scripting
The Multiselect field has a slug
Each option for the target multiselect field has a slug
In order to do this a user can use the following syntax to check an option in a field:
check_answer("field_slug","option_slug")
Where "field_slug" is the slug for the target multiselect field you want to update, and "option_slug" is the slug for the option that you want to check. Both of these slugs must be wrapped in double quotations for this to work.
You would use very similar syntax in order to uncheck an option:
β
uncheck_answer("field_slug","option_slug")
You will need one line of this code for every option you want to check or uncheck.
You can also wrap this in an if statement:
β
if answers.field1 == "True" then
check_answer("multiselect_1","option_1")
check_answer("multiselect_1","option_2")
check_answer("multiselect_1","option_4")
elseif answers.field1 == "False" then
uncheck_answer("multiselect_1","option_1")
uncheck_answer("multiselect_1","option_2")
uncheck_answer("multiselect_1","option_4")
check_answer("multiselect_1","option_3")
else
uncheck_answer("multiselect_1","option_1")
uncheck_answer("multiselect_1","option_2")
uncheck_answer("multiselect_1","option_3")
uncheck_answer("multiselect_1","option_4")
end
In the above code, if field1 equals True, then we set options 1, 2 and 4.
If field1 equals False, then we uncheck options 1, 2, and 4, and check option 3
If field 1 is anything other than True or False, we uncheck all options.
If you have any questions about this functionality, please reach out to a VerticalChange representative.
