I want my Record producer to redirect to a homepage after submitting the record with a message of the RITM submitted?

Raju Singh1
Tera Expert

I want my Record producer to redirect to a homepage after submitting the record with a message of the RITM submitted?

I am trying with this code but still it is not redirecting me to the home page and redirects me to the RITM page.

function onSubmit() {

    //Type appropriate comment here, and begin script below

    function onLoad() {    

        setTimeout('clearMsg()', 4000);  

}  

function clearMsg(){  

  g_form.clearMessages();

  producer.redirect = producer.redirect = "https://katerradev.service-now.com/nav_to.do?uri=/home.do"  

//action.setReturnURL(current);

    //window.top.close();

}  

}

Capture_Code.JPG

Capture.JPG

Capture1.JPG

1 ACCEPTED SOLUTION

leebooth
Kilo Expert

In your record producer script


find_real_file.png



The below is what I've used for an incident which redirects to the service catalog screen. Adjust the message to your needs.




  1. var msg = "The incident " + current.number + " has been opened based on your report.<br/>";
  2.       msg += "Due to the potentially sensitive nature of the accident, viewing is restricted to the Facilities team.<br/>";
  3.       msg += "They will contact you if they require any further information.";
  4. producer.redirect = "catalog_home.do?sysparm_view=catalog_default";
  5. gs.addInfoMessage(msg);

View solution in original post

11 REPLIES 11

Shahed Shah1
Tera Guru

You don't want to put redirect logic in the onSubmit script, because the user will be redirected before the request is submitted. Also, the producer.redirect variable is a server-side component, which will not work in a client-side script. You are best working this logic and using the variable in the record producer script itself.


Raju Singh1
Tera Expert

Have not put the message line yet but I am not sure How shall I put it..


You can use the gs.getMessage() function in the producer script


So you're script would have something in the format of:


gs.addInfoMessage('Hi there');


producer.redirect = "url_comes_here";