somebody help to debug the email script code

Nikita35
Kilo Guru

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {

var instance = new GlideRecord('asmt_assessment_instance');
instance.addQuery('task', current.sys_id);
instance.query();
while(instance.next())
{
url = '<a href="'+gs.getProperty('glide.servlet.uri') +'nav_to.do?uri=%2Fassessment_take2.do%3Fsysparm_assessable_sysid=' +instance.sys_id + 'sysparm_assessable_type%3D4b8c6704dbaa7300f3e3a08a4896191f'">'+'Click here'+'</a>';
template.print(url);
}

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

find_real_file.png

 

regards

 

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

try

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
	
	var instance = new GlideRecord('asmt_assessment_instance');
	instance.addQuery('task', current.sys_id);
	instance.query();
	while(instance.next())
		{
		url = '<a href="'+gs.getProperty('glide.servlet.uri') +'nav_to.do?uri=%2Fassessment_take2.do%3Fsysparm_assessable_sysid=' +instance.sys_id +'sysparm_assessable_type%3D4b8c6704dbaa7300f3e3a08a4896191f">Click here</a>';
		template.print(url);
	}
	
})(current, template, email, email_action, event);

View solution in original post

19 REPLIES 19

Hey Nikita,

You're missing a comma after the last plus sign; should look like this:

find_real_file.png

LMAO, I Meant "Click here"

Please put the lines of code

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

I misinterpreted the code. It looks like there is a variable your adding at the end. Try this:

 

find_real_file.png

Nikita35
Kilo Guru

hi Guys,

Looks like this one opens the survey correctly but doesn't capture the responses in the survey response.

After submitting the survey I didn't get any "You have completed this survey"

Can you guys please help on this?

Detailed description can be found in below question.

https://community.servicenow.com/community?id=community_question&sys_id=cdaf493cdb2abf401cd8a345ca96...

Regards