Skip to main content
Known Participant
November 16, 2021
Question

Rich formatting for text poppulating via if condition

  • November 16, 2021
  • 1 reply
  • 634 views

Good day peeps, I am trying to do rich formatting within a text field which is generating text based on dropdown value selected. I want to text to be generated as:

 

HEADING

1) Specs

2) Summary

3) Multiple lines keep going.

 

var selectedPackage = this.getField("Equipment").value;
if (selectedPackage=="Tractor") event.value = "Heading in BOLD with center alignment, 1) Specs 2) Summary 3) multiple lines keep going.";
else if (selectedPackage=="Trailer") event.value = "Trailer also has detailed Specification in multiple lines.";
else if (selectedPackage=="Weigh Scale") event.value = "Weigh Scale also  has detailed Specification in multiple lines."; // etc.
else event.value = "";

 

Please let me know if I am not clear in my instructions. Any help would be highly appreciated.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
November 17, 2021

You need to use the richValue property of the event object and apply to it an array of Span objects, each one representing a string with specific formatting settings.

See the documentation of richValue (under either event or field) for an example.

Najam5D24Author
Known Participant
January 10, 2022

Thank you very much, sorry somehow i missed the answer and it worked perfectly fine with richValue function.

However, I have another issue now. I would like to add hyperlink in the text. For example:

 

else if (selectedPackage=="Hose and Strainers") event.richValue = [{text: "ITEM SPECIFICATIONS\n\n", fontWeight: 800},

{text: "3 Inches Hoses • 3 inch Semi Rigid Suction Intake Hose\n"},

{text: "Please visit www.test123.com for details"}];

 

when I do this, it appears as plain text, is there anyway to create hyperlink within Text ""?

try67
Community Expert
Community Expert
January 10, 2022

Not with a script, unfortunately.