We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Redirect to different table record from business rule.

Not applicable

I have written a onBefore Update Business rule on a checkbox on a change request table, that if the checkbox changes to True I'm inserting a record a record in Outage table. Now I want to redirect to that record also once the record is inserted in the table.

I tried:

gs.setRedirect();

gs.setRedirectURL();

action.setRedirect();

action.setRedirectURL();

window.location.href();

window.location.replace();

none of these seems to work. 

Can anyone tell me what I'm doing wrong ?

 

This is my Business Rule script:

createOutageM2M();

function createOutageM2M() {
current.update();
if(current.start_date.nil() || current.end_date.nil())
{
gs.addErrorMessage('Planned Start Date or Planned End Date can not be empty.');
current.setAbortAction(true);
}
else
{
var outage = new GlideRecord("cmdb_ci_outage");
outage.setValue("type", "planned");
outage.setValue("cmdb_ci", current.cmdb_ci + "");
outage.setValue("task_number", current.sys_id + "");
outage.setValue("begin", current.start_date + "");
outage.setValue("end", current.end_date + "");
var outageSysId = outage.insert();

var task_outage = new GlideRecord('task_outage');
task_outage.setValue("task", current.sys_id + "");
task_outage.setValue("outage", outageSysId);
task_outage.insert();

This code is basically same as Create Outage UI Action.

2 REPLIES 2

Jaspal Singh
Mega Patron

Hi Jainil,

 

Can you try,

 

var getmyrul=gs.getProperty('instance_name'); //gets the instance name

var url='https://'+getmyurl+'.service-now.com/cmdb_ci_outage.do?sysparm_change=' + current.sys_id;

action.setRedirectURL(url);

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Not applicable

Hi Jaspal,

Sorry for the late reply. This also seems to not working. I tried changing the URL to:

var url='https://'+getmyurl+'.service-now.com/cmdb_ci_outage.do?sys_id=' + outage.sys_id;

This also didn't work.