Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Ankur Bawiskar
Tera Patron

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

}

AnkurBawiskar_0-1735379820233.png

 

 

Output:

Native:

AnkurBawiskar_1-1735379820220.png

 

 

Portal:

AnkurBawiskar_2-1735379820212.png

 

 

Comments
Yakshitha
Tera Contributor

Hi @Ankur Bawiskar 


The above code is not working in Native UI. And also how to make this variable bold and red in RITM form?

davidwilhel
Tera Contributor

Any kind of DOM manipulation is against best practices and should not be done. This kind of parctice is why so many instances get to an unusable state and firms have no choice but to start over with a new instance.

 

Just push back and say no, we cannot do this type of enhancement since it is against best practices.

Version history
Last update:
‎12-28-2024 01:59 AM
Updated by:
Contributors