UI Action - Insert and Stay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 12:21 PM
Hello All,
I have created a UI Action to copy the change request and View Rule (name: ITO).
Everything is working fine except it does not stay on the new record.
Here is the script:
var gr = new GlideRecord("change_request","&sysparm_view=ITO&sysparm_view_forced=true");
gr.initialize();
gr.category = current.category;
gr.u_category_type = current.u_category_type;
gr.u_category_item = current.u_category_item ;
gr.cmdb_ci = current.cmdb_ci ;
gr.priority = current.priority ;
gr.risk = current.risk ;
gr.impact = current.impact ;
gr.urgency = current.urgency ;
gr.short_description = current.short_description ;
gr.description = current.description ;
gr.u_ito = current.u_ito ;
gr.assignment_group = current.assignment_group ;
gr.assigned_to = current.assigned_to ;
gr.u_need_justification = current.u_need_justification ;
gr.change_plan = current.change_plan ;
gr.backout_plan = current.backout_plan ;
gr.test_plan = current.test_plan ;
gr.u_test_results = current.u_test_results ;
gr.u_notification_plan = current.u_notification_plan ;
gr.u_verification_plan = current.u_verification_plan ;
gr.state = current.state ;
gr.insert();
action.setRedirectURL(current);
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 12:27 PM
Try:
action.setRedirectURL(gr);
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 02:44 PM
I did try that already and it is not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:36 PM
Hi,
Per all documentation and my own experience, using gr is the appropriate thing to use IF you're wanting to route to the new record. You only use "current" when you want to stay on the same record you were already in. You said you wanted to go to the new record, the new record is associated with gr, per the variable you used.
See: https://www.servicenowelite.com/blog/2013/11/23/setredirecturl-and-setreturnurl for other examples of what I'm talking about.
As far as the only thing I see odd...is:
var gr = new GlideRecord("change_request","&sysparm_view=ITO&sysparm_view_forced=true");
You're saying it's working, but I would recommend to try just:
var gr = new GlideRecord('change_request');
and then:
action.setRedirectURL(gr);
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 05:51 AM
Hi,
I just wanted to check-in on this and see how things were going. If my reply above helped you and is correct, please mark it as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!