Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Display variable text with dyanamic values from other variables in red color

Damayanti Sarod
Tera Guru

I have a requirement wherein I have to create 4 below variables named
Requested For, Location, Start Date and End Date

For the 5 th variable, type: checkbox, I need to write a dynamic text in red color
'I acknowledge that by submitting this request, I am delegating [Requested For]’s work items to [Location] for the period of [Start Date & Time] through [End Date & Time]. '

For this I have created a checkbox variable named 'user_confirmed' and a UI policy with below code in order to populate the dyanamic text
function onCondition() {
var requestedFor = g_form.getDisplayValue('requested_for');
var delegateName = g_form.getDisplayValue('location');
var startDate = g_form.getDisplayValue('start_date_time');
var endDate = g_form.getDisplayValue('end_date_time');
g_form.setDisplay('user_confirmed', true);


var labelText = 'I acknowledge that by submitting this request, I am delegating ' + requestedFor + '’s work items to ' + location+ ' for the period of ' + startDate + ' through ' + endDate;

g_form.setLabelOf('user_confirmed', labelText);
g_form.setMandatory('user_confirmed', true);

 

}

As per the above code the dyanamic value  in var labelText is getting populated  ,but need to populate the value of var labelText in red color. How can we achieve this?

1 REPLY 1

Tanushree Maiti
Tera Sage

Please refer this links, see if it helps you:

Solved: How to add color to "Check Box Text" in service c... - ServiceNow Community

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: