- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 10:30 AM
Hello All,
I am attempting to click a related link, on the incident form, and have it carry values over to the new custom form. I am using a UI action and testing with the number field.
Coming from: Incident Table (incident)
Going to: Custom Table (u_dispatch_email_template)
Here is my code currently:
var num = current.getValue("number");
var url = 'https://service-now.com/nav_to.do?uri=%2Fu_dispatch_email_template.do?v=1&sysparm=u_incident_number='+num;
gs.setRedirect(url);
It is going to the right place when clicked but not populating the number field.
Thanks,
Ben
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 07:00 AM
Hi Ben,
here is the corrected code
you are sending the value incorrectly send the parameter as sysparm_u_incident_number
if the field on new table is string then use this
var num = current.getValue("number"); // use if the field on new table is string
var url = 'https://service-now.com/nav_to.do?uri=%2Fu_dispatch_email_template.do?v=1&sysparm_u_incident_number=' + num;
gs.setRedirect(url);
if the field on new table is reference to incident table then use this
var sysId = current.getValue('sys_id'); // use if field on new table is reference to incident table accordingly set the value in the url
var url = 'https://service-now.com/nav_to.do?uri=%2Fu_dispatch_email_template.do?v=1&sysparm_u_incident_number=' + sysId;
gs.setRedirect(url);
on load on the table u_dispatch_email_template should be
function onLoad(){
var gURL = new GlideURL();
gURL.setFromCurrent();
var number = gURL.getParam("sysparm_u_incident_number");
g_form.setValue('fieldName',number);
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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
08-27-2019 10:32 AM
Try doing just current.number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 10:38 AM
You code should be
var num = current.getValue("number");
var url = '/nav_to.do?uri=%2Fu_dispatch_email_template.do?sys_id=-1&sysparm_query=u_incident_number='+num;
gs.setRedirect(url);
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 06:26 AM
Hi Sanjiv,
I used your code. When I added a:
gs.addInfoMessage('Current Incident Number is '+ num);
It displays the correct incident number. However, it still is not populating the field on the new form.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 07:00 AM
Hi Ben,
here is the corrected code
you are sending the value incorrectly send the parameter as sysparm_u_incident_number
if the field on new table is string then use this
var num = current.getValue("number"); // use if the field on new table is string
var url = 'https://service-now.com/nav_to.do?uri=%2Fu_dispatch_email_template.do?v=1&sysparm_u_incident_number=' + num;
gs.setRedirect(url);
if the field on new table is reference to incident table then use this
var sysId = current.getValue('sys_id'); // use if field on new table is reference to incident table accordingly set the value in the url
var url = 'https://service-now.com/nav_to.do?uri=%2Fu_dispatch_email_template.do?v=1&sysparm_u_incident_number=' + sysId;
gs.setRedirect(url);
on load on the table u_dispatch_email_template should be
function onLoad(){
var gURL = new GlideURL();
gURL.setFromCurrent();
var number = gURL.getParam("sysparm_u_incident_number");
g_form.setValue('fieldName',number);
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader