- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 08:49 AM
I have an onChange Catalog Client Script which is checking for change to a name field.
I would like to then have this name display within the display value variable I have on the form.
I've tried g_form.setValue('display_var', newValue); and g_form.setLabelOf('display_var', newValue); but neither have updated the display label.
What's the scripting solution to this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2025 12:16 PM
For anyone curious I did some digging and ServiceNow specify that this actually shouldn't be possible and is expected behavior.
This has been addressed on KB0758098: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0758098
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 11:19 AM
@MBarrott
could you please create the function changeFieldLabel and use that one instead?
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 11:31 AM
@Medi C I tried it but it came back with a Javascript error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 04:59 PM
Could you please share the error message/screenshot?
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 07:15 PM
Hi @MBarrott
I tried reproducing your issue. g_form.setLabelOf() method is working fine for me on Service Portal but not on Native UI. Refer below screenshots:
Before Client Script Execution:
After Client Script Execution:
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 06:51 AM
Hi @Amit Verma - this is what I did but it wasn't for a single-line text field (that works in the Service Portal).
The variable I'm trying to change dynamically is a Display label - Plain text.