Take me to the survey link should be redirected to service portal

Shweta Kasbe1
Tera Contributor

Take me to the survey link should be redirected to service portal

Please guide me in this.

find_real_file.png

var html = new AssessmentUtils().getInstanceLinkHTML(current);
template.print(html);

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello Shweta Kasbe,

if you have created a notification on asmt_assessment_instance table then you can use the below email script to redirce the user to take survey in portal:

In the url below script I have used /sp?id=take_survey where sp is default portal in my Personal Instance you need to replace that with your portal name

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
	var instanceName = gs.getProperty("instance_name");
	var instanceURL = "https://" + instanceName + ".service-now.com/sp?id=take_survey&instance_id=" + current.getUniqueValue();
	template.print('<a href="' + instanceURL + '">Click here to take Survey</a>');

})(current, template, email, email_action, event);

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

View solution in original post

3 REPLIES 3

Jaspal Singh
Mega Patron
Mega Patron

Hi Shweta,

It calls for script include AssessmentUtils() which has function: getInstanceLinkHTML()

This should ideally take you to portal. Can you check for line 827 or so. Something as below is what I could find.

		var instanceURL = gs.getProperty("glide.servlet.uri");
		var overrideURL = gs.getProperty("glide.email.override.url");
		var url = "";
		if(this.redirectToPortal() == 'true'){
			if(asmtRec.allow_public)
				url = instanceURL + this.defaultServicePortal + '?id=public_survey&instance_id='+instance;
			else
				url = instanceURL + this.defaultServicePortal + '?id=take_survey&instance_id='+instance;
		}

See if it meets your need i.e. if the If-else condition are satisfied or not.

Mahendra RC
Mega Sage

Hello Shweta Kasbe,

if you have created a notification on asmt_assessment_instance table then you can use the below email script to redirce the user to take survey in portal:

In the url below script I have used /sp?id=take_survey where sp is default portal in my Personal Instance you need to replace that with your portal name

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
	var instanceName = gs.getProperty("instance_name");
	var instanceURL = "https://" + instanceName + ".service-now.com/sp?id=take_survey&instance_id=" + current.getUniqueValue();
	template.print('<a href="' + instanceURL + '">Click here to take Survey</a>');

})(current, template, email, email_action, event);

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

Mohith Devatte
Tera Sage
Tera Sage

hello @shweta Kasbe ,

i assume that your notification is on survey table which is why you are passing the current object to the script include and that script include function is returning the native view link

instead of using this script include just do this 

var url = "<a href='your_portal_prefix?id=take_survey&instance_id='"+current.sys_id+">"+"click here to take the survey"+</a>;


template.print(url);

Hope this helps 

please mark my answer correct if this helps you