Copy link to clipboard
Copied
Hello, I recently created a fillable form that integrates with a Smartsheet product. How do I apply conditional formatting to color code a text field auto populated from a different application (ie, "Red" = change fillColor to color.red, "Yellow"=change fillColor to color.yellow, etc.)
Any help you can provide is greatly appreciated.
Edwina -
Copy link to clipboard
Copied
As the field's custom calculation script you can add something like this:
if (event.value=="Red") event.target.fillColor = color.red;
if (event.value=="Yellow") event.target.fillColor = color.yellow;
etc.
If the data is imported from an external source you would need to add a command to execute all of these scripts when the file is opened, by adding this code as a doc-level script:
this.calculateNow();
Copy link to clipboard
Copied
Hi, thank you for the feedback. Yes, you are correct, data is imported from an external source. Following are the changes I made to my original script:
Unfortunately, the fill color did not change per my criteria. Please advise.
Copy link to clipboard
Copied
After importing the data you have to re-open the file.
Copy link to clipboard
Copied
There's another option I discovered recently, that doesn't require re-opening the file, or calling calculateNow.
Try placing the code as the custom Format script of the field, and see if that works any better...
Copy link to clipboard
Copied
Hi, I linked my data fields to the fillable form, downloaded, and then re-open the PDF document -- the field color (Overall Project Status) did not change.
Will adding the calculation script to an 'Actions' function help? Not sure if that is an alternative solution or not?
Thanks again for your help.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi, I experimented with a Custom Format/Keystroke Script but it simply changed the field's default color to yellow ---
var v=this.getField("Project Status").valueAsString;
if(v=="Red")event.target.fillColor=color.red;
else event.target.fillColor=color.yellow;
Unfortunately, I cannot forward an attachment in this forum.