Service Portal - Custom List - Display Field Label NOT Field Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 11:14 PM - edited 09-27-2023 11:18 PM
Hi ServiceNow Masters,
I have a custom list displayed on the service portal however there is an issue I am hoping someone can help me to finish this script below so that the column headers will display the Label Value of the field and NOT the field name.
I understand from digging that the label values are stored in the sys_documentation table but I assume there would need to be a lookup to that table for each field name value in the array and then either create a new array with the label values from the sys_documentation table. I cannot figure out how to do this so any scripting help would be greatly appreciated.
SCRIPT:
These column headers are the field names from the core_company table and there are a couple of custom fields in that table.
in the sys_description table I can see the entries as per below and I want to display "Support Email" instead of "u_support_email" and "Support Phone" instead of "u_support_phone".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 11:31 PM
Hi @phil34
try to use gr.[field name].getLabel();
When you call field in header
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 04:28 AM
Hi Kalyani,
I am not sure how to incorporate that in the script I am not very good at scripting I tried
data.header = $sp.getValue('field_list.label'); (Did'nt Work)
If you can show me where and how to update the code that would be great.
Cheers
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2023 10:47 PM
Hi @phil34
Below you can try this
json[data.fieldList[i]] = gr.getLabel(data.fieldList[i]);
Please try and let me know if it helpful and not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 01:47 AM
Hello Kalyani,
Sorry to be so stupid but I cannot figure out how to update my script to accommodate your line of code I have put the code below would be great if you can adjust the entire script to accommodate your suggested line?
Your Line = json[data.fieldList[i]] = gr.getLabel(data.fieldList[i]);
Put it where? in this code
SCRIPT:
Cheers
Phil