How do i add color and change font to "Check Box Text" in service catalog/portal?

Bradley Bush
Mega Sage

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:)

BradleyBush_0-1740607036731.png

 

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);

}

  

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

@Bradley Bush 

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.

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

Hi Ankur, the DOM is not working, and i've tried a widget also. not sure where to go from here...

@Bradley Bush 

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.

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

Bradley Bush
Mega Sage

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);
}