Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How do I add auto text based on value in numeric field?

Avatar

Level 2

Need help... I'm trying to add auto text to a text field based on a value in a numeric field. I want my text field (summary box) to say "Passed" if the value (score box) is equal to 10 and the field to say "Not Passed" if the value is equal to less than 10. My numeric field is being calculated by selecting drop-down lists.

Thanks in advance for your help.

Ed Watson

Here's a link to the document I created...

https://files.acrobat.com/?trackingid=KGLIT#folder/c3106c32-2e69-4a5f-8ef2-94d25623dbfb

1 Accepted Solution

Avatar

Correct answer by
Level 10

Try this:

if (NumericField1.rawValue < 10) {

     TextField1.rawValue = "Did Not Pass";

}

else {

     TextField1.rawValue = "Passed";

}

View solution in original post

6 Replies

Avatar

Level 4

Its giving me the below error while accessing the file

"The file you are trying to access could not be found. The file may have been deleted or moved in another session".

Thanks,

Vipin

Avatar

Level 2

I think I figured it out.  I used the following script:

if(NumericField1.rawValue ==1){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==2){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==3){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==4){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==5){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==6){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==7){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==8){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==9){TextField1.rawValue = "Did Not Pass"}

if(NumericField1.rawValue ==10){TextField1.rawValue = "Passed"}

There's probably a cleaner way to do the same thing but at least this works for now.  Hope this helps someone else.

Avatar

Correct answer by
Level 10

Try this:

if (NumericField1.rawValue < 10) {

     TextField1.rawValue = "Did Not Pass";

}

else {

     TextField1.rawValue = "Passed";

}

Avatar

Level 2

Hi Jono.  Thanks, I knew there was a better way to write the script. 

On another note, is there a way to prevent the Text field from displaying the result until all selections in the drop-down fields have been made.  Maybe the field can even say something like "Please make all selections".

Avatar

Level 10

That's really going to depend on what your form looks like. You would need a loop to go through and check the values of all the dropdowns. And depending on how the form was put together that could get tricky.