Redirecting URL in Business rule

Khaled RAJHI
Tera Contributor

Hi Community,

 

I'm trying to write a Business Rule that creates a new Problem record after changing Incident State to On Hold and On Hold Reason = awaiting Problem

How can I redirect the page to the new Problem Record ? I tried gs.setRedirectURL(); and gs.setRedirect(); and the two methods were failed

 

Below the script :

    var gr = new GlideRecord('problem')
    gr.initialize();
    gr.short_description = current.short_description;
    gr.description = "Problem created from incident "+current.number+" which its State changed to On Hold";
    gr.assignment_group = current.assignment_group;
    gr.insert();
    gs.addInfoMessage("Problem "+gr.number+" is created after changing incident "+current.number+" to On Hold");
    gs.setRedirectURL(gr); Failed
    gs.setRedirect(gr); Failed
8 REPLIES 8

Sohail Khilji
Kilo Patron
Kilo Patron

Try this :

 

 

 

 

 var gr = new GlideRecord('problem')
    gr.initialize();
    gr.short_description = current.short_description;
    gr.description = "Problem created from incident "+current.number+" which its State changed to On Hold";
    gr.assignment_group = current.assignment_group;
    gr.insert();
    gs.addInfoMessage("Problem "+gr.number+" is created after changing incident "+current.number+" to On Hold");
    gs.setRedirectURL('build your record url here');

 

 

 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji,

Same behaviour, problem created but the window is still on incident form

 

KhaledRAJHI_0-1707309261473.png

 

Hi @Khaled RAJHI,

 

May i know what type of business rule your using ? You must be using Async business rule for this... Because we have 2 operations happening >> 1 the incident itself if receiving the changes 2. A new record is being created on incident changes... 

 

So here you go to Wait for incident updation first...

 

Alternatively, Instead of creating a business rule for redirection you can use gs.addinfomessage() to show your newly created problem as hyper link... by which user can be redirected. (You also have OOTB Problem field on incident record to check the problem creation...)

 

 var gr = new GlideRecord('problem')
    gr.initialize();
    gr.short_description = current.short_description;
    gr.description = "Problem created from incident "+current.number+" which its State changed to On Hold";
    gr.assignment_group = current.assignment_group;
    gr.insert();
    gs.addInfoMessage("Problem "+gr.number+" is created after changing incident "+current.number+" to On Hold");
    gs.setRedirectURL('build your record url here');

 

I hope this help...

 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi,

Im using an "After" Business Rule with conditions

Incident State = On Hold

On Hold Reason = Awaiting Problem

I want that after saving incident, the page is redirected automatically to the new created Problem Record, I tried

gs.setRedirectURL('/problem_list.do?sysparm_query=active%3Dtrue&sysparm_view=');

and nothing has changed, the page still on incident form