- 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-28-2019 11:39 AM
Thank you all for your help! I messed around with what you had and it ended up working!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 09:49 AM
Is u_incident_number a reference field? If so your script should be
var num = current.getValue("sys_id");
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-27-2019 10:44 AM
Hello Ben,
Try passing sys_id:
var num = current.getValue("sys_id");
var url = "https://service-now.com/u_dispatch_email_template.do?sys_id="+num ;
gs.setRedirect(url);
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 11:09 AM
Redirecting to the form with the URL params doesnot make the form fields to be auto populated,
On the form, you need to have an onload script where you are parsing the URL for the specific parameters and then setting the values onto the fields is also needed.
Check this script as suggested in the other comments
function onLoad(){
var gURL = new GlideURL();//Instantiating GlideURL
gURL.setFromCurrent();//set the current URL to gURL
var number = gURL.getParam("sysparm_u_incident_number");//parse the param passed on click of UI action from URL
g_form.setValue('fieldName',number);//set the field on the custom table form
}
Hope this helps
Mark this response as correct if that helps
Thanks,
Siva