- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 02:28 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 03:46 AM
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);
}
Output:
Portal:
Native:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 02:53 AM
I would suggest you to create new variable with new label and write catalog client script to hide the old variable from the variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 03:03 AM
You can refer this link where I have shared solution on how make label as bold
enhance as per your need to change the inner html value
How to make text of Label type in Bold
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 03:33 AM
I was able to add the new label for Portal
For native you need to use DOM manipulation somehow
Old - My Label
New - My New Label
Create onLoad Catalog Client Script
function onLoad(){
setTimeout(function(){
var newLabel = 'Do you need data service along with the request';
var olLabel = 'Do you need a official service along with request.';
var aTags = this.document.getElementsByClassName("ng-binding");
var found;
for (var i = 0; i < aTags.length; i++) {
//alert(aTags[i].textContent);
if (aTags[i].textContent.toString() == olLabel) {
//alert('found');
//aTags[i].style.fontWeight = 'bold';
aTags[i].innerHTML = newLabel;
break;
}
}
}, 3000);
}
Output: For Portal
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 03:46 AM
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);
}
Output:
Portal:
Native:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader