color a variable

abjaffrey
Giga Guru

Hi 

 

I have a multi row variable se with one variable as yes/no type, it is hidden in portal and a widget script collects the data from portal,

in ritm form if the value is NO it should be highlighted in red, if yes then no change.

 

is it possible, any help

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@abjaffrey 

yes it's possible.

Create catalog client script which Applies to MRVS variable set and Applies on RITM view

Then use this to color the label

but remember it will mark the color if someone opens that row of MRVS on RITM

Output:

color mrvs.gif

Script:

Remember to give correct variable name and no value during comparison

function onLoad() {
    //Type appropriate comment here, and begin script below
    
    if (g_form.getValue('server_os') == 'test') {
        g_form.getControl('server_os').setAttribute('style', 'color:red');
    }

}

It won't highlight it on RITM form. Possibly it would require DOM manipulation which is not recommended

 

AnkurBawiskar_1-1737119843952.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @abjaffrey 

 

I doubt it can be do able on variable, if it is the field we can try with field decorator.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@abjaffrey 

yes it's possible.

Create catalog client script which Applies to MRVS variable set and Applies on RITM view

Then use this to color the label

but remember it will mark the color if someone opens that row of MRVS on RITM

Output:

color mrvs.gif

Script:

Remember to give correct variable name and no value during comparison

function onLoad() {
    //Type appropriate comment here, and begin script below
    
    if (g_form.getValue('server_os') == 'test') {
        g_form.getControl('server_os').setAttribute('style', 'color:red');
    }

}

It won't highlight it on RITM form. Possibly it would require DOM manipulation which is not recommended

 

AnkurBawiskar_1-1737119843952.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

HI Ankur,

 

Thanks for the help, but the MRVS is read only. any way to chieve it on form view?

@abjaffrey 

As mentioned you will have to use DOM manipulation and check each row in html

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader