Copy link to clipboard
Copied
Hello,
I am attempting to add color to my variables that are inserted into standard text.
All varaiables can be colored "red" or rgb 255,0,0 or hex FF0000.
Here is my current code,
var frequency = this.getField("Dropdown8").valueAsString;
var date = this.getField("Date7_af_date").valueAsString;
var target = this.getField("Text9").valueAsString;
var calcmonths = this.getField("Text99").valueAsString;
var periodend = this.getField("Dropdown88").valueAsString;
var dropdown3Value = this.getField("Dropdown3").valueAsString;
if (dropdown3Value === "Consolidate Debt Service Coverage Ratio C&I, CRE, AgCash, Non-Profit") {
event.value = "This is test paragraph 1 " + target + " and " + frequency + " and " + calcmonths + " and " + date + " and " + calcmonths + " end paragraph.";}
else if (dropdown3Value === "Consolidate Debt Service Coverage Ratio, Less Distributions C&I, CRE, AgCash") {
event.value = "This is a test of paragraph 2 " + frequency + " and " + date + " and " + target + ".";}
else if (dropdown3Value === "Consolidate Minimum Current Ratio C&I, CRE") {
event.value = "This a test paragraph 3 " + target + " and " + periodend + " and " + date + ".";}
else if (dropdown3Value === "Consolidate Maximum Debt/TNW C&I, CRE") {
event.value = "This is a test paragraph 4 " + target + " and " + periodend + " and " + calcmonths + " end.";}
else
event.value = "";
Thank you!
Copy link to clipboard
Copied
To do that you must define the field as having Rich Text Formatting, and then you'll need to specify the (rich) value as an array of Span objects, which can each have a different text color.
For example, this line:
event.value = "This is test paragraph 1 " + target + " and " + frequency + " and " + calcmonths + " and " + date + " and " + calcmonths + " end paragraph.";
Will become:
var spans = [];
spans.push({text: "This is test paragraph 1 ", textColor: color.black});
spans.push({text: target, textColor: color.red});
spans.push({text: " and ", textColor: color.black});
spans.push({text: frequency, textColor: color.red});
spans.push({text: " and ", textColor: color.black});
spans.push({text: calcmonths, textColor: color.red});
spans.push({text: " and ", textColor: color.black});
spans.push({text: date, textColor: color.red});
spans.push({text: " and ", textColor: color.black});
spans.push({text: calcmonths, textColor: color.red});
spans.push({text: " end paragraph.", textColor: color.black});
event.richValue = spans;
Copy link to clipboard
Copied
Thank you for the response,
Once I apply this to my text box, (text5>properties>custom cal), I do not get any output.
Is that the correct setup?
Copy link to clipboard
Copied
Did you also add the first lines, which define the variables?
Check the JS Console for errors.
Copy link to clipboard
Copied
You need to include it into your script, and replace your line like this:
if (dropdown3Value === "Consolidate Debt Service Coverage Ratio C&I, CRE, AgCash, Non-Profit") {
event.value = "This is test paragraph 1 " + target + " and " + frequency + " and " + calcmonths + " and " + date + " and " + calcmonths + " end paragraph.";}
with:
if (dropdown3Value === "Consolidate Debt Service Coverage Ratio C&I, CRE, AgCash, Non-Profit") {
event.richValue = spans;}
For other conditions you need to create another span object, for example 'spans2'.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more