- 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 09:21 AM
this should work. Did it not run in native or portal? Is that variable name correct?
Please share the complete script along with screenshots.
g_form.setLabelOf('display_var', newValue);
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-10-2025 10:38 AM
Hi @Ankur Bawiskar,
Running it in Service Portal. Variable names are correct.
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '')
{
return;
}
alert(newValue);
//Type appropriate comment here, and begin script below
g_form.setLabelOf('emp_agreement', newValue);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 10:51 AM
@MBarrott
Could you please use the solution on:
“Actually this solved it...for both the ITIL Service Catalog and the Service Portal:
Here is the UI Script function:
“
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:05 AM
Hi @Medi C - I did find this and the solution shown would suggest I'm already doing that (setLabelOf)