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

Custom validation in constant sum question.

  • January 27, 2023
  • 3 replies
  • 92 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+21
  • QPN Level 5 ●●●●●
  • 306 replies
  • January 27, 2023

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 ●●●●●●●●
  • 6083 replies
  • January 27, 2023

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 ●●
  • 61 replies
  • January 29, 2023

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