Correct way to make a form label bold? (For Service Portal)

Ted18
Tera Contributor

I have 2 different ways to make a label on a form bold.

  • A catalog client script
  • And a field style


I am sure I could get it to work for either but the issue is that I do not what object to select to apply the CSS. What I have been trying is:

function onLoad() {

var el = g_form.getControl('add_new_rule_label'); // The name of the label variable

el.style.fontWeight = 'bold';

}

Also with getLabel instead.

Is there a different method I should be using?

 

8 REPLIES 8

Sudhanshu Talw1
Tera Guru

Can you try this:

g_form. getControl('impact').style.fontWeight="bold";

 

If the variable is referemce type:

try this:

var myVar = $('sys_display.' + g_form.getControl('caller_id').id);

myVar.style.fontWeight="bold";

 

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

Jyoti8
Kilo Guru

Hi Ted,

Refer this Url : https://www.servicenowguru.com/system-ui/ui-scripts-system-ui/modifying-label-form-fields-client-scr...

Try these ways :

function onLoad() {
//Change the description label to 'My New Label' with bold red text
changeFieldLabel('description', 'My New Label', 'red', 'bold');
}

function changeFieldLabel(field, label, color, weight){
try{
var labelElement = $('label_' + g_form.getControl(field).id);
labelElement.select('.sn-tooltip-basic').each(function(elmt) {
elmt.innerHTML = label;
if(color)
elmt.style.color = color;
if(weight)
elmt.style.fontWeight = weight;
});
}catch(e){};
}

 

or 

changeFieldLabel('description', 'My New Label', 'green', 'bold');
 
 
 
I hope it will help you.
 
If you find my answer is helpful or correct Please mark it accordingly.
Thanks.

Abdul Azeez
Mega Guru

Hi Ted,

 

Can you please try like below:

 

function onLoad() {

 var l = g_form.getLabel('short_description');

l.style.fontWeight='bold'; }