Requirement Overview
A Zoho Survey user wants to display an error message whenever the customer answers Question A with a value less than 10% of Question B.
Use-case
Loan Eligibility Check for a Real Estate Business: A real estate company uses Zoho Survey to pre-qualify potential homebuyers who are interested in purchasing property and seeking home financing. As part of this survey, they collect information about the user's intended purchase amount and the down payment they are willing to make.
The company wants to ensure that users are serious buyers and meet the minimum financing criteria. One such rule is that the down payment should be at least 10% of the purchase amount to qualify for in-house loan offers or partner bank financing.
Current Challenges to achieve this directly
As of now, we do not have a direct 'Validation Rule' feature to display an error message based on the customer input on the Zoho Survey questions.
Permissions & Availability
The Portal Admin user or users with Department Admin and User role can access the Survey's which are associated with the Department the user is part of.
Solution: Step-by-Step Implementation Guide
1) Please navigate to the respective survey for which you would like to perform the validation.
2) Drag and drop the 2 Number (Data Type) questions in the Question Builder and name them as Purchase Amount and Down Payment.
3) Drag and drop the Heading/Description question to display an error message whenever the Down Payment value is less than 10% of the Purchase Amount.
How will we apply the criteria to trigger and display an error message?
Two factors are involved in this case, one is Display Logic for the question Heading/Description, and the second one is Java Script where we are going to define the criteria to display an error message.
In the Display Logic of the Heading/Description field, please ensure that you've chosen Display this question only if a certain condition is met.
Step 2: Condition
We will have to use two conditions here:
1) If Down Payment (Question) is Answered
AND
2) If Javascript Snippet returns True.
Below is an image attached that shows Display Logic and Condition:
In the C2 (Condition 2), we will have to use the below sample code.
var fieldA = application.survey.question.F.response;
var fieldB = application.survey.question.G.response;
if (fieldA && fieldB)
{
return fieldB < (0.1 * fieldA);
}
else
{
return false;
}
Shared sample code explanation:
1. Using script, you would require to fetch 1st Field(Question F).
fieldA = F.response;
→ Gets the response value from question F.
2. Then, you would require to fetch 2nd Field(Question G).
fieldB = G.response;
→ Gets the response value from question G.
3. Then, use a IF condition and check if both the fields are empty or not.
if (fieldA && fieldB)
→ Checks that both fields have a response (i.e., neither is empty or null).
4. At last, fetch both field values and validate further.
return fieldB < (0.1 * fieldA);
→ If both fields have responses, it checks:
Is the response to question G less than 10% of the response to question F?
If the condition C2 is true, then it will display the Heading/Description question. Else, it will not display the Heading/Description question.
How "fieldA" and the "fieldB" captures the Purchase amount and the Downpayment?
We could capture it by using the "Insert Variable". The image below demonstrates the mentioned option.