- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 07:02 AM
Hi ,
In Incident form Show Impacted (reference field ) and Show Start Date are two columns and These two columns are part of one Table only.
When I select the Show Name in show impacted column then it need to display related Show Date in Show Start Date field.
Instead it is showing value as undefined when selecting particular show name even after it has the date.
Please provide suggestions.
Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 07:51 AM - edited 04-02-2025 07:56 AM
Try below script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var userObject= g_form.getReference("u_show_impacted", doAlert);
function doAlert(userObject) {
g_form.setValue('u_show_start_date', userObject.getValue('u_start_date')); //Make sure to use the correct field name
}
}
NOTE: While setting the date value you are not picking the correct field name. Check that. Also please share the snap of your onchange client script configuration.
As per my script, you onchange client script should be configured on "Show impacted" field and UI type should be "All"
Regards ,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 08:41 AM
you should have script when value changes so do this and not when form loads
Ensure all field names are correct
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue == '')
g_form.clearValue('u_show_start_date');
if (oldValue != newValue)
var userObject = g_form.getReference("u_show_impacted", doAlert);
function doAlert(userObject) {
g_form.setValue('u_show_start_date', userObject.getValue('u_start_date'));
}
}
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
04-03-2025 03:54 AM
Hi @Ankur Bawiskar ,
Thank you so much for your quick assistance and I achieved it with your initial code itself by adding date format conditions (bold and Underlined).
Here is the Script for reference
Client Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 08:55 AM - edited 04-02-2025 08:55 AM
Thank you @J Siva i.e., Correct and it is populating date now but format taking is in opp format when loading
Table data:
Incident reflection: