script to redirect to an url from catalog client script by onsubmit

rick48
Tera Contributor

i want to redirect to an incident page by onsubmit using catalog client script

how to do this?

1 ACCEPTED SOLUTION

use this script,

 

var a = g_form.getValue('requested_variable_name');

var b = g_form.getValue('short_description_variable_name');

var c = g_form.getValue('description_variable_name');

var d = g_form.getValue('state_variable_name');

var url = "https://dev22966.service-now.com/incident.do?sys_id=-1&sysparm_query=requested="+a+"&sysparm_query=short_description="+b+"&sysparm_query=description="+c+"&sysparm_query=state="+d

g_navigation.openPopup(url);

check all the fields before run this script, It should work

View solution in original post

34 REPLIES 34

Ahmmed Ali
Mega Sage

Hello,

you can user below statement in onSubmit script to redirect to another URL.

window.location.href='provide URL Here';

 

Note: This will cause the form to not get submit.

 

Not sure what is business requirement. If you can tell me the use case, then I may have better approach for the same.

 

Thanks,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

I have created four fields in a catalog  and when i fill up the fields and when i click on ordernow it should   redirect to an  incident ticket.

find_real_file.png

 

this is the code :

function onSubmit() {
   //Type appropriate comment here, and begin script below
     var URL = "https://dev22966.service-now.com/incident.do?sys_id=d78ae3a2db55a300b364d170cf961930&sysparm_record_target=incident&sysparm_record_row=1&sysparm_record_rows=43&sysparm_record_list=active%3Dtrue%5EORDERBYDESCnumber";   
  top.window.location = URL;  
	
	
var ga = new GlideAjax('incident');
ga.addParam('sys_id',g_form.getUniqueValue());
ga.addParam('caller_id', g_form.getValue('requestedfor'));
ga.addParam('state', g_form.getValue('state'));
ga.addParam('description',   g_form.getValue('description'));
ga.addParam('short_description',   g_form.getValue('shortt'));



}

i dont want to use record producer

Use

 

getTopWindow().NavPageManager.get().getPane('gsft_main').loadLinkFromUrl("/incident.do?sys_id=d78ae3a2db55a300b364d170cf961930&sysparm_record_target=incident&sysparm_record_row=1&sysparm_record_rows=43&sysparm_record_list=active%3Dtrue%5EORDERBYDESCnumber");

 

Regards,

Chandra Prakash

 

thanks for reply;

 

 it didn't work and url should redirect  to incident and map the catalog item fields to incident form