Need to redirect user to service portal using create request ui action

Ashwini35
Tera Contributor

Hi All,

I have a requirement to use create request ui action on incident form on click of which user should redirect to service portal and specific catalog item which they wants to raise a request from the incident. I am trying to use oob ui action "Create Request" this is working fine in Native ui and request details are getting captured on incident form and incident details are getting copied in parent field of the request form. But when I am trying to changes in the same code for service portal redirection its not copying details from incident to request and vice versa. Can someone please help me with capturing details while redirecting to sp as well. Please refer below code for native ui and for service portal - 

UI Action code - Native UI

current.update();
var url;
var activeCatalogsCount = sn_sc.Catalog.getCatalogCount();
if (activeCatalogsCount === 1) {
url = "catalog_home.do?sysparm_view=catalog_default&sysparm_parent_table=" + current.sys_class_name + "&sysparm_parent_sys_id=" + current.sys_id;
}
else {
url = "catalogs_home.do?sysparm_view=catalogs_default&sysparm_parent_table=" + current.sys_class_name + "&sysparm_parent_sys_id=" + current.sys_id;
}


action.setRedirectURL(url);

 

 

 

UI action code service portal - 

current.update();
gs.addInfoMessage('Incident '+ current.number +' will get cancelled automatically upon request submission');var url = "sp?id=sc_category&sys_id=d258b953c611227a0146101fb1be7c31&catalog_id=-1&spa=1" + current.sys_id; 

action.setRedirectURL(url);

 

 

Please help me with redirection to sp and incident number details should be copied in parent field of request form

3 REPLIES 3

Ashwini35
Tera Contributor

Can anyone please guide on this?

Harsh Vardhan
Giga Patron

You can try something like this. 

 

UI Action Script :

 

var ItemID = 'YourCatalogItemSysID'; // Set Your item sys id
var srLink = '/sp?id=sc_cat_item&sys_id='+ItemID ;
srLink += '&sysparm_description=' + 'Testing';
action.setRedirectURL(srLink + '');

 

Catalog client Script: 

 

function onLoad() {
	//Type appropriate comment here, and begin script below
	var des= getParameterValue('sysparm_description') ? getParameterValue('sysparm_description') : false;
	if (des) {
		g_form.setValue('description', des);
	}
}

function getParameterValue(name) {
	name = name.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
	var regexS = "[\\?&]" + name + "=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(this.location.href);

	return (results ? unescape(results[1]) : "");
}

 

Thanks,

Harsh

 

Is there any way to capture the incident details while redirecting to service portal catalogs instead of single catalog?