Custom validation in constant sum question. | Experience Community
Skip to main content

Custom validation in constant sum question.

  • Jan 27, 2023 11:13 AM UTC
  • 3 replies
  • 121 views

dipeshsingh
Level 2 ●●
Forum|alt.badge.img+12

Hi All,
I have a constant sum question. I want to add a validation here that SUM OF A,B and C MUST BE AT LEAST 50% IN COMBINATION, ELSE TERMINATE. Can we do this with JS?
image.png

3 replies

Forum|alt.badge.img+23
  • QPN Level 5 ●●●●●
  • Jan 27, 2023 7:42 PM UTC

Hi dipeshsingh
This thread might help. Please have a look.
PS: The above attached case is very similar to yours, you might do some changes in the provided custom code and you'll get the solution.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Jan 27, 2023 10:33 PM UTC

dipeshsingh,
If the question is the last in the block, then you can perform the calculation and terminate logic in the survey flow (replace QIDxx with actual question id):
Set Embedded Data:
ABDsum = $e{ q://QIDxx/ChoiceNumericEntryValue/1 + q://QIDxx/ChoiceNumericEntryValue/2 + q://QIDxx/ChoiceNumericEntryValue/4 }

Branch:
If Embedded Data ABDsum Is Less Than 50

End of Survey


dipeshsingh
Level 2 ●●
Forum|alt.badge.img+12
  • Author
  • Level 2 ●●
  • Jan 29, 2023 4:56 PM UTC

Hi TomG

My question was not in the end of block by I did a similar thing. I created a additional text entry question to validate and terminate. BTW thanks :)
image.png