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.

need too add background color for label?

meera5
Tera Contributor

I want to add background color for label with grey color

1 ACCEPTED SOLUTION

Hi,

this script worked for me in portal

1) onLoad catalog client script

function onLoad(){

	setTimeout(function(){ 
		var aTags = this.document.getElementsByClassName("ng-binding");
		var searchText = "My Label"; // give the text for the label to be searched
		var found;

		for (var i = 0; i < aTags.length; i++) {
			if (aTags[i].textContent.toString() == searchText) {
				aTags[i].style.backgroundColor = 'grey';
				break;
			}
		}
	}, 3000);

}

Output:

find_real_file.png

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Sushma R1
Tera Expert

try right click on the field and write this code on configure label

var labelcolor = g_form.getLabel('u_crequests.u_risk_rla');  labelcolor.style.color = 'grey'; 

 

Hit correct answer or helpful if it was 🙂

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Can you share screenshot for your question?

Regards
Ankur

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

I need  background grey color for this one "Please select the domain of the ADM account(s) to be onboarded" 

find_real_file.png

Hi,

so it's label variable and you want to add background color to it?

OOB this is not possible but you can use DOM which is not recommended

I have shared solution here on how to make label bold and it works in both native + portal

enhance it for background color

https://community.servicenow.com/community?id=community_question&sys_id=733a7af1db86e4907d3e02d5ca96...

Regards
Ankur

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