How to get the field value for Record producer from URL and redirecting the user to a page after submitting the record

Priyanshu
Giga Expert

Hello all,

I have created a record producer with three field Channel Name (Single line text), Channel ID (Single line text) and User name (reference type referring user table). Now my concern is how to get the Value for all these field from url and on submit how to redirect the user to different page.

Requirement is:

I need to give a URL(ServiceNow URL) to our client, in that URL they will be passing the two value Channel name and channel id and once end user will hit that user he will be asked to login incase there is no session and after login, i need to capture his user id. now i have all the three fields value i need to create a record in a table without any manual interruption from the end user. once the record is created i need to redirect the end user to a page where i will be showing some success message that your record has been created.

To achieve the requirement i have created a record producer with three field now how to get the value from url and what URL i should be sharing with the client so that they can pass the value.

NOTE: I can not user Rest API here as the response of the API will be either in XML or JSON format and i need to redirect end user to a page once record is created.

 

Please help me out here with scripting and best practice.

1 ACCEPTED SOLUTION

vandna
Tera Guru

Hi,

 

You can use GlideUrl function to get the current url parameter and you can redirect Record producer using 'producer.redirect="home.do";' line at the end of the producer script.

 

GlideUrl example.

 

var grURL= new GlideURL();

//Set the current URL

grURL.setFromCurrent();


var strUrl = grURL.getURL();

grURL.getParam(<url parameter name>);

View solution in original post

19 REPLIES 19

Deepak Ingale1
Mega Sage

Hi,

Here is an article which describes the methods to achieve the requirement what you have

 

https://community.servicenow.com/community?id=community_blog&sys_id=596dea29dbd0dbc01dcaf3231f96190b

 

Note: Please mark reply as correct if it has answered your question or mark it as helpful based on the impact

I am going through the Brad blog which you have referred and will try my best to achieve it. will check with you back in case i will not be able to do it.

function getParameterValue(name) {

      var url = document.URL.parseQuery();

      if (url[name]) {

              return decodeURI(url[name]);

      } else {

              return;

      }

}

 

Can you help me what URL i need to pass here. do i need to pass the URL of record producer and how to redirect the user to a UI page

vandna
Tera Guru

Hi,

 

You can use GlideUrl function to get the current url parameter and you can redirect Record producer using 'producer.redirect="home.do";' line at the end of the producer script.

 

GlideUrl example.

 

var grURL= new GlideURL();

//Set the current URL

grURL.setFromCurrent();


var strUrl = grURL.getURL();

grURL.getParam(<url parameter name>);