- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 12:08 AM
I'm not sure if I've uncovered a bug...
I've created a Survey that is triggered when an incident is resolved, and I'd like to include the URL of the survey in the incident resolution email that is sent to the Caller.
I found an email notification script that, at face value, retrieves/constructs the URL for insertion into the email: incident_survey. When I use this, however, the URL returned is incorrect. I get "https://instancename.service-now.com/1"
After a bit of searching I found a solution where the incident_survey script was modified to use a function from the AssessmentUtils script include (https://community.servicenow.com/community?id=community_question&sys_id=dd5f6b73db8927408e7c2926ca9619af&anchor=answer_55eca084dbd1a340f7fca851ca9619fd&view_source=searchResult).
Specifically, it executes the following line to create the URL:
var link = new AssessmentUtils().getAssessmentInstanceURL(current.sys_id);
This solution also does not create a well-formed URL.
Digging deeper into the getAssessmentInstanceURL function, I suspect the problem is the way in which the parameter is consumed.
// Survey Instance Table URL
getAssessmentInstanceURL : function(/* String */instance) {
var gr = new GlideRecord("asmt_assessment_instance");
var type = '';
if (gr.get(instance)) {
var asmtRec = new GlideRecord("asmt_metric_type");
asmtRec.addQuery("sys_id", gr.getValue("metric_type"));
asmtRec.query();
if (asmtRec.next())
type = asmtRec.getValue("sys_id");
}
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;
}
else{
if (overrideURL)
instanceURL = overrideURL;
else
instanceURL = instanceURL + "nav_to.do";
url = instanceURL + '?uri=assessment_take2.do%3Fsysparm_assessable_type=' + type + '%26sysparm_assessable_sysid=' + instance;
}
return url;
},
The issue seems to be with using the 'instance' parameter (which I believe is a sys_id from the task table), as a key into the 'asmt_assessment_instance' table (i.e. the "if( gr.get(instance))" statement on line 5 above). If I'm reading this correctly then this search will never return a record.
So at this point there are a couple of possibilities:
- I'm using the email notification script incorrectly
- There is a bug in the function above
If the function above is incorrect, then I presume the instance parameter should instead be used to search the asmt_assessment_instance table on the task_id field. If that's the case, do I also need to filter for assessment instances that are active? Is it possible for there to exist multiple assessment instances for a single task_id? Would additionally filtering by state resolve this?
I'm open to suggestions.
Cheers,
Adrian
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 12:18 AM
The email you are sending must come from the Assessment table.
At the time a resolution email from incident fires, the Assesment record doesn't exist yet.
Your options are:
- Re-engineer your Incident Resolution email to fire from the Assessment Instance table, and make it look like an Incident Resolution email
- Modify the Service Portal Survey page to search for an assessment by record sys_id. By the time the User receives the email and clicks the link, the Assessment record will exist.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 12:18 AM
The email you are sending must come from the Assessment table.
At the time a resolution email from incident fires, the Assesment record doesn't exist yet.
Your options are:
- Re-engineer your Incident Resolution email to fire from the Assessment Instance table, and make it look like an Incident Resolution email
- Modify the Service Portal Survey page to search for an assessment by record sys_id. By the time the User receives the email and clicks the link, the Assessment record will exist.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 12:22 AM
Well that would explain it then. Possibility 1 it is!
Thanks for the info.
<strikethrough>An unfortunate consequence is that I'll be sending multiple notifications (i.e. incident resolution + survey) in response to resolving an incident. I'll have a think about how to work around that...</strikethrough>
So then I should disable the incident resolution notification and replace it with an Assessment table insert notification.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 12:22 AM
Hi,
Yes Paul is write. We have to write email notification and email script on Assessment table.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 12:28 AM
Can you disable your incident resolution notification,
trigger a sys_event containing your resolution details (or at least a sys_id so you can query the record for details)
and consume this from an Assessment table based notification?
Not ideal but possibly better than spam - if it works.