- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 07:51 AM
Hi,
I have two Yes/No Question Variables on a Catalog Item form and a third Answer (Single Text) variable.
The requirement is to set the Answer variable based on the responses to both questions. How can I do this on a Catalog Item form? Appreciate your help.
If Conditions...
IF Question 1 = Yes <AND> Question 2 = No <OR> Question 1 = No <AND> Question 2 = No, set Answer to Phone
IF Question 1 = Yes <AND> Question 2 = Yes, set Answer to Handheld Team Review
IF Question 1 = No <AND> Question 2 = Yes, set Answer to Badge
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 11:31 AM
@Mike Cory If you want to see the changes in real time then instead of creating an onSubmit script, you can chose to create onChange script on question1 and question2 fields
Here is the onChange script sample for Question1
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Get values of Question 1 and Question 2
var question1 = g_form.getValue('question1'); // Replace 'question1' with the actual field name
var question2 = g_form.getValue('question2'); // Replace 'question2' with the actual field name
// Initialize variable for Answer
var answer;
// Check the conditions
if (question1 === 'Yes' && question2 === 'No') {
answer = 'Phone';
} else if (question1 === 'No' && question2 === 'No') {
answer = 'Phone';
} else if (question1 === 'Yes' && question2 === 'Yes') {
answer = 'Handheld Team Review';
} else if (question1 === 'No' && question2 === 'Yes') {
answer = 'Badge';
}
// Set the value of the Answer field
g_form.setValue('answer', answer); // Replace 'answer' with the actual field name
}
You can create an exact replica of the same script for question 2 and the changes will reflect in real time on the answer field.
Please mark the response helpful and accepted solution if it manages to address your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 11:54 AM
Works perfect. Thank you!