- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 01:19 AM
How to get the value of Label of a Table at client side ?
The backend name of Label Field is 'label' only. To get table name we have g_form.getTableName(). How to get the table label name as shown in below scrrenshot. Please suggest
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 02:44 AM
Well, if you want to change the header title then you might have to use DOM which is not recommended.
For this purpose, we have type field on the form, right?
If you still want to go with DOM, then try utilizing the below scripts on change_request table.
Display Business Rule.
(function executeRule(current, previous /*null when async*/ ) {
var chgType = current.type.getDisplayValue();
var tblName = current.getClassDisplayValue();
g_scratchpad.title = chgType + ' ' + tblName;
})(current, previous);
onLoad() Client Script
function onLoad() {
var arr = top.document.getElementsByClassName('navbar-title-caption');
arr[0].innerHTML = g_scratchpad.title;
}
Output:
In case, if it does not work then you can uncheck Isolate script check box in the client script and try again. See the below image for reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 02:32 AM
It also shows the Table Label i.e referring about the Text above the displayed value , like how to display the Text as Normal Change Request in header and Emergency Change Request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 02:33 AM
Hi,
only way is to use DOM manipulation which is not good practice.
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-21-2022 02:44 AM
Well, if you want to change the header title then you might have to use DOM which is not recommended.
For this purpose, we have type field on the form, right?
If you still want to go with DOM, then try utilizing the below scripts on change_request table.
Display Business Rule.
(function executeRule(current, previous /*null when async*/ ) {
var chgType = current.type.getDisplayValue();
var tblName = current.getClassDisplayValue();
g_scratchpad.title = chgType + ' ' + tblName;
})(current, previous);
onLoad() Client Script
function onLoad() {
var arr = top.document.getElementsByClassName('navbar-title-caption');
arr[0].innerHTML = g_scratchpad.title;
}
Output:
In case, if it does not work then you can uncheck Isolate script check box in the client script and try again. See the below image for reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 03:31 AM
Will try to make the customer understand, otherwise will go by this.
Thanks for sharing , i tried and it worked !!!