Copy link to clipboard
Copied
Hi - I'm trying to get a text field to show "Owed to Us" if the amount in another field is positive, and to show "Owed to Them" if the amount in that other field is negative. How do I do that?
Not exactly, in fact I had a syntax error in my code anyway (which is now fixed).
Since you have 3 conditions let's use an old fashion "if".
if(event.value < 0)
this.getField("MessageField").value = "Owed to Them"
else if(event.value > 0)
this.getField("MessageField").value = "Owed to Us";
else
this.getField("MessageField").value = "Even Dealer Trade";
Copy link to clipboard
Copied
The best way to do this is to add a Validation script to the field that shows the positive or negative value.
this.getField("MessageField").value = (event.value < 0)?"Owed to Them":"Owed to Us";
Copy link to clipboard
Copied
You didn't specify what you want if value is 0?
Code provided by Thom will show "Owed to us" when value is 0 or if field is empty, also code is missing '?' at:
(event.value < 0)?"Owed
Copy link to clipboard
Copied
Thank you! If the Value is 0 it should say "Even Dealer Trade" - So if I understand this correctly, would I need to write
this.getField("MessageField").value = (event.value < 0)"Owed to Them":"Owed to Us"
this.getField("MessageField).value = (event.value = 0)"Even Dealer Trade"
Or is there some and / or connection that I need to also insert?
Copy link to clipboard
Copied
Not exactly, in fact I had a syntax error in my code anyway (which is now fixed).
Since you have 3 conditions let's use an old fashion "if".
if(event.value < 0)
this.getField("MessageField").value = "Owed to Them"
else if(event.value > 0)
this.getField("MessageField").value = "Owed to Us";
else
this.getField("MessageField").value = "Even Dealer Trade";
Copy link to clipboard
Copied
Thank you!!