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

James Gragston
Tera Guru

Your 'url' variable should hold a String value so the the only time you need a '+' sign is when the string is added to a variable. That being said, you shouldn't need the plus symbol before the 'Click here' part of the url string because it's itself a string; you shouldn't need to add a string to a string. You can also get rid of the quotes surrounding this same section. Your string should look like this:

 

find_real_file.png

Hope this answer helped or solved your problem. If so, please mark it as such. Thanks!

James Gragston - CloudPires

DScroggins
Kilo Sage

Hello,

 

Please update line 10 to the following:

var 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>';

 

The text 'Click Here' is already a string and as such does not need to be concatenated into the rest of the URL string.

 

Hope this helps.

--David

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);

Nikita35
Kilo Guru

find_real_file.png

 

still the same 😞