Change font weight and size on a label variable

ddemar
Giga Contributor

Hello,

We would like to change the font weight and size of a few label variables in one of our catalog items that is accessible from the Service Portal. I've seen several older posts addressing this topic and I have tried an onLoad script suggested, g_form.getControl('label_variable').setAttribute('style', 'font-weight: bold;color:red'), but I get a javascript error.

I have also seen references to setLabel(), but I can't find any helpful documentation that further explains usage. 

Is this acheivable? Many thanks in advance for your assitance.

6 REPLIES 6

Namrata Khabale
Giga Guru

Hey ddenar,

Refer the threads below it will help you:

https://community.servicenow.com/community?id=community_question&sys_id=7de8c15f1b3a4098fff162c4bd4b...

 

https://community.servicenow.com/community?id=community_question&sys_id=f2628beddb98dbc01dcaf3231f96...

 

Mark Correct and Helpful if you find my response worthy!!!

 

Best Regards,

Namrata.

Kunal Varkhede
Tera Guru

Hi,

 

In addition to @Namrata   also check below

https://www.servicenowguru.com/system-ui/field-styles-service-catalog-variables/

 

 

Thanks,

Kunal

Hi Kunal,

Thank you for your reply. I had already tried the suggestions in the article you recommended. This is one of the attempts where it throws a java script error. When UI type is ‘Desktop,’ I don’t see the error, but as well, the script does not work to apply the bold style to the label.

 

function onLoad() {

//Set styles for the 'office_request_options' label variable

 

var myVar2 = g_form.getControl('office_request_options');

 

myVar2.style.fontWeight = 'bold';

}

@ddemar did you ever get this to work??  I'm trying to do the same with no success. I agree that the suggestions in the article were tried but I keep getting a javascript error indicating "TypeError: $ is not a function".

Brandon