Make variable label as bold in native and portal
New article articles in ServiceNow Community
·
Dec 28, 2024
·
article
Many a times there is a requirement to add some css to variable label such as making bold.
I am sharing sample script for the same, you can enhance it as per your requirement.
You can use this catalog client script onLoad and make the Label variable as Bold
Script: This will work in both native + portal
1) Ensure Isolate Script field is set to false for this client script
2) This field is not on form but from list you can make it false
function onLoad(){
setTimeout(function(){
if(window != null){
// native
g_form.getControl('variableName').setAttribute('style', 'font-weight: bold;color:blue');
}
else{
// portal
var aTags = this.document.getElementsByClassName("ng-binding");
var searchText = "My Label"; // give the label name here
var found;
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].textContent.toString() == searchText) {
aTags[i].style.fontWeight = 'bold';
break;
}
}
}
}, 3000);
}
Output:
Native:
Portal:
View original source
https://www.servicenow.com/community/service-operations-workspace/make-variable-label-as-bold-in-native-and-portal/ta-p/3136908
Ankur Bawiskar