- 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 03:49 AM
Hi Ankur,
Thank you for the above. I will try it in my instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 03:55 AM
It would surely work provided you follow all the steps.
Would you mind marking my response as correct and helpful as I have shared the working solution
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-14-2021 11:10 PM
Hi Ankur,
Thank you it worked.
Can you please explain me the above code. Actually i am not able to figure out these steps and also why do we need to make 'Isolate script' to false??
Does making this field false cause any other impact?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2021 11:15 PM
Glad to know that my script worked.
Please mark response as correct and helpful.
Isolate Script false means it would allow DOM manipulation. No other impact as this change is only for this script and not instance level
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
‎09-22-2023 05:38 AM
not working on me