Adding a Redirect and Info Message to a Record Producer

Record producers in Service-now allow users to create records on any table directly from the Service catalog interface. Typically, record producers are used to allow users to create incident or change request records. When the record is submitted using a record producer, you are redirected directly to the generated record. Oftentimes it is more desirable to redirect users back to the catalog or their homepage and provide them with an information message telling them that their record has been created. Here’s a script that allows you to do that.

The following script can be used to redirect a user to a page other than the record created by the record producer. It also adds an information message containing a link to the record generated. The information message will be displayed at the top of the page that the user gets redirected to. To use this script, simply paste it into the ‘Script’ field on any record producer in your Service-now instance.

  • You can add the value of anything from the generated record to the message by accessing the ‘current’ record object followed by the name of the field you want to access (current.short_description, current.number, etc.).
  • You can add the value of any record producer variable to the message by accessing the ‘producer’ object followed by the name of the variable you want to access (producer.var1, producer.var2, etc).
//Create the html contents of the information message
var link = '<a class="breadcrumb" href="' + current.sys_id + '">' + current.number + '</a>';
var message = 'Change ' + link + ' has been created.
message += 'Thank you for your submission.';

//Add the information message

//Redirect the user to the homepage
producer.redirect = '';

Here’s another example that shows how you can access record producer variables using the ‘producer’ object. This script takes the values of the ‘caller_id’, ‘cmdb_ci’, and ‘contact_me’ variables, and combines them to be populated into the ‘work_notes’ field on the generated record. It performs a similar operation to populate the ‘short_description’ field.

//Get the values of record producer variables to populate the 'work_notes' and 'short_description' on generated record
var notes = "Please contact customer with new password via: " + producer.contact_me;
notes += '\nCaller : ' + producer.caller_id.getDisplayValue();
notes += '\nSystem : ' + producer.cmdb_ci.getDisplayValue();
notes += '\nContact : ' + producer.contact_me;
//Populate the 'work_notes' field
current.work_notes = notes;
//Populate the 'short_description' field
current.short_description = 'Reset the password for ' + producer.caller_id.getDisplayValue() + ' on ' + producer.cmdb_ci.getDisplayValue();

//Populate reference fields
current.caller_id = gs.getUserID(); //Populate Caller with current user
current.assignment_group.setDisplayValue('Hardware'); //Populate Assignment Group (name must be unique)

//Create an information message
var message = 'An incident ' + current.number + ' has been opened for you.
message += 'The IT department will contact you for further information if necessary.
//Add the information message
//Redirect the user to the 'ess' homepage
producer.redirect = '';

Date Posted:

March 25, 2010

Share This:


  1. Rose July 5, 2011 at 9:59 am

    I tried this redirect on our CMS page but it takes me to the home page within the iFrame… the header is included in the iFrame. How can I get it to redirect back to the homepage outside of the iFrame?

    producer.redirect = ‘’;

    • Mark Stanger July 5, 2011 at 11:30 am

      The CMS is different because of the way it handles frames. In order to get the redirect to work in the CMS interface you have to set up a new page for your site that contains a dynamic content block with javascript to redirect the user to the correct place. Then you just use ‘producer.redirect’ to redirect to your new page, which contains the code to redirect outside of the inner frame. The dynamic content block on your new page will need to contain code like this to redirect and break out of the inner frame.

      <script>top.location = '';</script>
  2. Michele November 1, 2011 at 1:56 pm

    Anyone know how force a record producer to update an existing record instead of inserting a new one? Is there an abort command you can put in the record producer script?

    • Mark Stanger November 1, 2011 at 2:25 pm

      Hey Michele,

      I’ve seen this done before. What you would need to do is use ‘current.setAbortAction(“true”)’ in your producer to abort the producer insert. Then your update would need to be a GlideRecord query and update.

  3. Ram Prakash Kutva Ramdoss March 1, 2012 at 12:15 am

    I have tried the script. Its working fine in IE & Google Chrome,but not in Mozilla Firefox. Why is it so?

    • Mark Stanger March 1, 2012 at 5:34 am

      I’ve never had an issue with this in Firefox so I’m not sure why it wouldn’t be working for you. If you can set it up and reproduce it in the ServiceNow demo instance I can take a look.

  4. AKL October 17, 2016 at 11:50 pm

    I found out that Info message doesn’t appear in chrome which is a known issue and will not be resolved.

    Another thing is that current.number doesn’t contain anything. I am unable to get the reference of created record in current object. So the message that is added in Firefox is like this-
    “An incident has been opened for you.
    The IT department will contact you for further information if necessary.”

    An IFrame with buster set to true will continue to expand the Firefox scroll bar (FF v49.01). If not, the the info message appears but the record producer shown is erroneous.

    • AKL October 18, 2016 at 12:03 am

      Regarding the current.number value, it will not work if “Assign a task number only upon insert (prevents unused numbers).” property is enabled.

Comments are closed.




Fresh Content
Direct to Your Inbox

Just add your email and hit subscribe to stay informed.