Can i change the label of a variable in form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 02:38 AM
Hi,
I have a variable 'Requested for' which is a variable in variable set . My requirement is that for a particular form , this requested for variable label should be changed to 'Owner name' .
Is on load client script the correct approach .
And if this is so , then will it also change the database name of the variable . I dont want the database name of requestd for i.e. requested_for to change . But only the label to be changed to 'Owner name''
Any leads on this is highly appreciated .
Regards,
Naresh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 02:42 AM
You can use OnLoad client script
g_form.setLabelOf('your variable',"the label you want to set") ;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 02:43 AM
Use the OOB setLabel of
function onLoad() {
changeFieldLabel('assigned_to', 'Assigned to');
function changeFieldLabel(oldLabel, newLabel) {
$j("span").filter(function() {
return ($j(this).text() === oldLabel);
}).html(newLabel);
}
Note : Make sure you Unchecked ISOLATED SCRIPT Checkbox. If its not available on the form then add it to form and do it or you can uncheck it from list view as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 02:44 AM
Hey,
You can create an onload client script and use g_form.setLabel() method.
Reference:- http://www.servicenowguru.com/system-ui/ui-scripts-system-ui/modifying-label-form-fields-client-scripts/
this reference might help you more
Mark helpful
Thanks & Regards
Simran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 03:05 AM
For portal you will have to use DOM manipulation so I won't recommend that.
Why not take this approach
1) Hide that variable for your particular catalog item
2) create new Label variable with Label as "Owner name"
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader