How to create UI action link to redirect to incident which was created

AnandKumar1
Tera Expert

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.

1 ACCEPTED SOLUTION

sachin_namjoshi
Kilo Patron
Kilo Patron

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);

 

View solution in original post

7 REPLIES 7

Allen Andreas
Administrator
Administrator

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!

Thank you so much Allen. Issue is resolved.

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!

sachin_namjoshi
Kilo Patron
Kilo Patron

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);