Redirect to survey once the incident is closed by user in service portal

Vishnu V Reddy
Tera Contributor

Hello everyone,

We have a widget on the incident form in Service portal in which we have a close incident button accessible by the customer. Once he clicks on the close incident button, right now it simply closes the incident and stays on the form.

We want to direct the user to the survey of this incident once the user clicks on close incident. How do we achieve this? What changes should I be making in the widget? I tried hardcoding the url using document.location = "?id=take_survey&instance_id=here comes the instance_id which is the sys_id of the survey".  But I am having hard time retrieving the "instance id/sys_id" of the survey in the widget controller that was created.

 

Looking to resolve this as soon as possible. Thank you.

6 REPLIES 6

Hi Snow_learner,

Make sure that caller is you! that widget has configured for the caller if the incident is not opened you will get that error. 
and I have recently done a survey from email basically email sends out when an incident is resolved with smilies faces. as soon they click the smile it will redirect to the portal with a preselected smile : 
find_real_file.png

Just readjust the code for your needs you should be good to go.
I have done in through an email script but you can do similar with your UI action button:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
	var sid = "";
	var asmt = new GlideRecord("asmt_assessment_instance");
	asmt.addEncodedQuery("state=ready^trigger_id="+current.sys_id);
	asmt.query();
	if(asmt.next()){
		sid = asmt.sys_id;
	}
	template.print("Some message?");
	template.print("<p></p>");
	
	var link4 = "/sp?id=ms_take_survey&instance_id="+sid+"&value=0";
	var link3 = "/sp?id=ms_take_survey&instance_id="+sid+"&value=1";

	
	template.print("<table style='width: 730px; height: 40px; border-collapse: collapse;' border=0 cellspacing=10 cellpadding=10>");
	template.print("<tr>");
	
	template.print("<td align=center style='color: black; font-family: segoe ui; font-size: 13pt;'>Very Satisfied</td>");
	
	
	template.print("<td align=center style='color: black; font-family: segoe ui; font-size: 13pt;'>Somewhat Satisfied</td>");
	
		
	template.print("</tr>");
	
	template.print("<tr>");
	template.print("<td align=center><a href='"+link4+"'><img src='face_1.png' width='40', height='40' alt=''/></a></td>");
	
	template.print("<td align=center><a href='"+link3+"'><img src='face_2.png' width='40', height='40' alt=''/></a></td>");
	
	template.print("</tr></table>");
	
})(current, template, email, email_action, event);

 

Please mark the reply as Helpful/Correct, if applicable. Thanks!

Shodi

Hi,

Please see this article for sleep function: https://community.servicenow.com/community?id=community_article&sys_id=d40f980edb8aaf801089e15b8a961...

 

See also http://stackoverflow.com/questions/1381751/onkeyup-javascript-time-delay


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!