Change label for catalog variable

sanvi
Tera Expert

Hi All,

I have a requirement to change the label of a variable in a catalog item, tried using 'setLabelOf' but its not working as its not supported for catalog forms and i cannot change the label directly because this variable is part of variable set which is being used by multiple other forms.

Can anyone suggest for any alternative. below are the requirement.

Existing label - Do you need a official service along with request.

New label - Do you need data service along with the request

1 ACCEPTED SOLUTION

@sanvi 

Here you go to make it work for both native + portal

onLoad Catalog Client Script on Your Catalog Item

UI Type - ALL

Isolate Script - False

a) This field is not on form but from list you can make it false

Script:

function onLoad(){

	setTimeout(function(){

		var newLabel = 'My Label';
		var oldLabel = 'My New Label';

		if(window != null){
			$j("span").filter(function() {
				return ($j(this).text() === oldLabel);
			}).html(newLabel);
		}
		else{
			var aTags = this.document.getElementsByClassName("ng-binding");
			var found;
			for (var i = 0; i < aTags.length; i++) {
				if (aTags[i].textContent.toString() == oldLabel) {					
					aTags[i].innerHTML = newLabel;
					break;
				}
			}
		}
	}, 3000);
}

find_real_file.png

Output:

Portal:

find_real_file.png

Native:

find_real_file.png

Regards
Ankur

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

View solution in original post

10 REPLIES 10

need help