How do i add color and change font to "Check Box Text" in service catalog/portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 02:00 PM
Hi, I need some help to get specific text to change color and size in a checkbox variable. In the example only the end of the text needs the modification "(access should only be granted to cost center manager and above)". I have tried a few examples and no luck. thank you:)
function onLoad(){
setTimeout(function(){
if(window != null){
// native
g_form.getControl('kha_budgeting').setAttribute('style', 'font-weight: bold;color:red');
}
else{
// portal
var aTags = this.document.getElementsByClassName("ng-binding");
var searchText = "access should only be granted to cost center manager and above"; // 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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 08:35 PM
is the DOM manipulation not working?
what debugging did you perform?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 10:09 AM
Hi Ankur, the DOM is not working, and i've tried a widget also. not sure where to go from here...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 01:17 AM
I will suggest to avoid DOM manipulation as it's not a good practice.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 10:56 AM
Hi, so i tried to set value this way and no success either
function onLoad() {
var description = "Budgeting - to view individual department budget plan files <br>" +
"<span style='color:red; font-weight:bold; font-size: larger;'> " +
"(access should only be granted to cost center manager and above)</span>";
g_form.setValue('kha_budgeting', description);
}