Submit Button Redirect to New record

Blayne
Mega Contributor

Using the Service Desk Call Plugin, I would like a call submit UI Action to open the record that was just created (incident/change).  I get to the table, but something is messed up in the link that opens up a new record and posts the previous number which was the actual insert.

 

answer = current.insert();
gs.include('ActionUtils');
var au = new ActionUtils();
current.doRedirect = true;
var redirect = current;
if (current.call_type == 'change_request'){
var modlink = 'change_request.do?sysid=';
redirect = modlink + redirect;
action.setRedirectURL(redirect);
}
else if (current.call_type == 'incident'){
var modlink = 'incident.do?sysid=';
redirect = modlink + redirect;
action.setRedirectURL(redirect);
}
else {
au.postInsert(current);}

1 ACCEPTED SOLUTION

Chris Sanford1
Kilo Guru

Instead of passing in the URL suffix to action.setRedirectURL() pass in a GlideRecord pointing to the record you want to see. Also you are putting 'current' at the end of your URL suffix which in this context would be the call record, not the incident or change so that URL suffix would not be valid.

answer = current.insert();
gs.include('ActionUtils');
var au = new ActionUtils();
current.doRedirect = true;
var redirect = new GlideRecord('task');
redirect.get(current.transferred_to.toString());

if(current.call_type == 'incident' || current.call_type == 'change_request') {
   action.setRedirectURL(redirect);
} else {
   au.postInsert(current);
}

View solution in original post

3 REPLIES 3

Blayne
Mega Contributor

I've created a new button to override the global submit button on the form, but still have issues opening the newly inserted record.

Community Alums
Not applicable

Hi Blayane,

 

If you could explain what exactly you are trying to do? meanwhile, can you try using.

 

action.setRedirectURL (current) ;

Chris Sanford1
Kilo Guru

Instead of passing in the URL suffix to action.setRedirectURL() pass in a GlideRecord pointing to the record you want to see. Also you are putting 'current' at the end of your URL suffix which in this context would be the call record, not the incident or change so that URL suffix would not be valid.

answer = current.insert();
gs.include('ActionUtils');
var au = new ActionUtils();
current.doRedirect = true;
var redirect = new GlideRecord('task');
redirect.get(current.transferred_to.toString());

if(current.call_type == 'incident' || current.call_type == 'change_request') {
   action.setRedirectURL(redirect);
} else {
   au.postInsert(current);
}