Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to add color to "Check Box Text" in service catalog???

Mr_m1
Tera Expert

How to add color to Check Box "Text" -> Adobe Acrobat in service catalog

 

As im not having Macros

Any ideas

Thanks

Mounish

 

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Mounish 

this worked for me in Native + Portal

Remember this uses DOM which is not recommended.

Ensure Isolate Script = False for this

Client Script: Isolate Script False

function onLoad(){

	setTimeout(function(){ 
		if(window != null){
			// native
			var z = document.getElementsByClassName("checkbox-label");
			for (k = 0; k < z.length; k++) {
				if(z[k].innerHTML == 'Adobe Acrobat'){
					z[k].style.color = 'red';
				}
			} 
		}
		else{
			// portal
			var aTags = this.document.getElementsByClassName("ng-binding");
			var searchText = "Adobe Acrobat";
			for (var i = 0; i < aTags.length; i++) {
				if (aTags[i].textContent.toString() == searchText) {
					aTags[i].style.color = 'red';
					break;
				}
			}
		}
	}, 3000);
}

find_real_file.png

find_real_file.png

Output: Native

find_real_file.png

Output: Portal

find_real_file.png

Please mark my response as correct and helpful to close the thread so that it benefits future readers.

Regards
Ankur

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

View solution in original post

19 REPLIES 19

Ankur Bawiskar
Tera Patron
Tera Patron

@Mounish 

this worked for me in Native + Portal

Remember this uses DOM which is not recommended.

Ensure Isolate Script = False for this

Client Script: Isolate Script False

function onLoad(){

	setTimeout(function(){ 
		if(window != null){
			// native
			var z = document.getElementsByClassName("checkbox-label");
			for (k = 0; k < z.length; k++) {
				if(z[k].innerHTML == 'Adobe Acrobat'){
					z[k].style.color = 'red';
				}
			} 
		}
		else{
			// portal
			var aTags = this.document.getElementsByClassName("ng-binding");
			var searchText = "Adobe Acrobat";
			for (var i = 0; i < aTags.length; i++) {
				if (aTags[i].textContent.toString() == searchText) {
					aTags[i].style.color = 'red';
					break;
				}
			}
		}
	}, 3000);
}

find_real_file.png

find_real_file.png

Output: Native

find_real_file.png

Output: Portal

find_real_file.png

Please mark my response as correct and helpful to close the thread so that it benefits future readers.

Regards
Ankur

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

Hi @Ankur Bawiskar 

 

Its working as expected, can i have the text in color only for Acrobat for that check Box - Text

 

please let me know 

 

Thanks 

Mounish

you can manipulate it.

if you want text color for Acrobat to be red then update as this

function onLoad(){

    setTimeout(function(){
        if(window != null){
            // native
            var z = document.getElementsByClassName("checkbox-label");
            for (k = 0; k < z.length; k++) {
                if(z[k].innerHTML == 'Acrobat'){
                    z[k].style.color = 'red';
                }
            }
        }
        else{
            // portal
            var aTags = this.document.getElementsByClassName("ng-binding");
            var searchText = "Acrobat";
            for (var i = 0; i < aTags.length; i++) {
                if (aTags[i].textContent.toString() == searchText) {
                    aTags[i].style.color = 'red';
                    break;
                }
            }
        }
    }, 3000);
}

Regards
Ankur

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

I had given that but it didn't work

when I gave the text as Adobe Acrobat it worked for me

try to debug and enhance.

Regards
Ankur

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