Copy link to clipboard
Copied
I'd like to write a script that matches specific text in part of the field value but not all of it. Is there a way to script that?
The logic would be if the field CONTAINS this specific text, change the text color. If not, keep the text color as black.
Here's what I've tried (tried in both validation and format script with no luck):
if(event.value >= "(T)") {
event.textColor = color.red;
}
else {
event.textColor = color.black;
}
Any suggestions?
If you want to check whether this string is anywhere within the value, use this:
if (event.value.indexOf("(T)")!=-1) {
Copy link to clipboard
Copied
If I change "event" to the defined doc level variable, It simply changes to red regardless. I want it to only change if "(T)" is present in the value.
Copy link to clipboard
Copied
You're using the wrong operator. ">=" means "larger than or equal to", which doesn't apply to strings.
Replace it with "==".
Copy link to clipboard
Copied
If you want to check whether this string is anywhere within the value, use this:
if (event.value.indexOf("(T)")!=-1) {