- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2020 07:56 AM
Hi Team,
I have a requirement to provide a link "open incident" in my custom table which should redirect to the incident which was already created.
I have stored the incident number in "u_incident" in my custom table.
I tried the below script in ui action. I have doubt in addquery.
condition: current.state =="inprogress"
Script:
var gr = new GlideRecord("incident");
gr.addQuery('u_incident', current.sys_id); // i have doubt in this query.
gr.query();
if(gr.next()){
var sysId = gr.sys_id;
var url = "incident.do?sys_id=" + sysId;
gs.print(url);
action.setRedirectURL(url);
}
Please help me.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2020 08:03 AM
use below code
var gr = new GlideRecord("incident");
gr.addQuery('sys_id', current.u_incident); // i have doubt in this query.
gr.query();
if(gr.next()){
var sysId = gr.sys_id;
var url = "incident.do?sys_id=" + sysId;
gs.print(url);
action.setRedirectURL(url);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2020 08:02 AM
Hi,
You'd want to use:
var gr = new GlideRecord("incident");
gr.addQuery('number', current.u_incident);
gr.query();
if(gr.next()){
var sysId = gr.sys_id;
var url = "incident.do?sys_id=" + sysId;
gs.print(url);
action.setRedirectURL(url);
}
So 'number' if the Incident number is stored in u_incident, but if it's a reference to the incident table...then you'd use 'sys_id' instead.
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
‎06-26-2020 08:19 AM
Thank you so much Allen. Issue is resolved.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2020 09:15 AM
Hi,
Thanks. Let me know from my post above if there was any issues with it, I felt it answered your question?
You can only have one reply marked as 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
‎06-26-2020 08:03 AM
use below code
var gr = new GlideRecord("incident");
gr.addQuery('sys_id', current.u_incident); // i have doubt in this query.
gr.query();
if(gr.next()){
var sysId = gr.sys_id;
var url = "incident.do?sys_id=" + sysId;
gs.print(url);
action.setRedirectURL(url);