Skip to main content
Participant
Nov 30, 2018 6:34 PM UTC
Answered

How to return a string based on a value in the box next to it?

Hello, 

I am making a dynamic form and I want the field "ScoringKey" to return a string based on a score that is calculated in the field next to it, "FinalScore". Is this possible? I cant seem to get the field "ScoringKey" to return a string no matter the parameters.

Basically

  • if final score is greater than 1.00 but less than 1.99 return “Unsatisfactory”
  • If final score is greater than 2.00 but less than 2.99 return “Needs Improvement”
  • If final score is greater than 3.00 but less than 3.99 return “Meets Expectations”
  • If final score is greater than 4.00 but less than 4.99 return “Exceeds Expectations”
  • If final score is equal to 5.00 than return “Outstanding”

This is what I have for code:

if (FinalScore < 2 && FinalScore > 0.99) text = "Unsatisfactory";

if (FinalScore < 3 && FinalScore > 1.99) text = "Needs Improvement";

if (FinalScore < 4 && FinalScore > 2.99) text = "Meets Expectations";

if (FinalScore < 5 && FinalScore > 3.99) text = "Exceeds Expectations";

if (FinalScore === 5) text = "Outstanding";

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Nov 30, 2018 7:13 PM UTC

Add this line to the start of your code:

var FinalScore = Number(this.getField("FinalScore").valueAsString);

And this line to the end of it:

event.value = text;

3 replies

Participant
Nov 30, 2018 7:18 PM UTC

That worked perfectly, thank you!!

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Nov 30, 2018 7:13 PM UTC

Add this line to the start of your code:

var FinalScore = Number(this.getField("FinalScore").valueAsString);

And this line to the end of it:

event.value = text;

Translate
Bernd Alheit
Community Expert
Community Expert
Nov 30, 2018 7:00 PM UTC

Where do you set the variable FinalScore?

Translate