How do I pass an assessment instance sysid and the survey sysid in a URL for a Survey in an email?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2016 08:46 AM
I have created a customer Survey. A very simple Likert scale survey with one question. The URL to the Survey is included in the Resolved Incident email we send to the caller inviting them to take the survey. Because a caller might have received more than one Resolved Incident email therefore may have multiple Assessment Instances in a "ready to take" status, I want to be sure that the link they click on brings them to the appropriate assessment instance. To do this, my email runs the following script:
>>>
/*-------------------------------------------------------------------------------------------------------------------*/
/* This section will look for the sysid of the Survey Instance for this particular incident */
/*------------------------------------------------------------------------------------------------------------------*/
var triggerInc = new GlideRecord('asmt_assessment_instance');
/* Current sysid is the emails associated Incident Number */
triggerInc.addQuery('trigger_id', current.sys_id);
/* The asmt_assessment_instance trigger_id is the Incident Number */
triggerInc.query();
var incNumber = "";
/* If we have a match ...*/
if (triggerInc.next()) {
/* incNumber = triggerInc.trigger_id; replacing with triggerinc.sys_id */
incNumber =triggerInc.sys_id;
}
var surveyURL = '<a href="https://scricdev.service-now.com/nav_to.do?uri=assessment_take2.do%3Fsysparm_assessable_sysid=' + incNumber +
'%3Fsysparm_assessable_type=f1f825004fdf4e40d6f32cee0210c7db">'+'Click Here' + '</a>';
>>
The resulting URL from a test email looks like this:
//scricdev.service-now.com/nav_to.do?uri=assessment_take2.do%3Fsysparm_assessable_sysid=ce714f9c4fda1e00f33f0195f110c765%3Fsysparm_assessable_type=f1f825004fdf4e40d6f32cee0210c7db
The first sysid is the Assessment/Survey Instance sysid. The second is the actual Survey sysid. Both of these were verified to be correct. However when the URL is clicked it creates a log error of invalid sysid.
I can think of no other way that one would ensure that the email's Incident ID would point to the correct Assessment/Survey Instance and the format of the URL seems to be correct.
Any ideas would be GREATLY appreciated as so far no one has been able to explain the error to me.
Respectfully
Greg Bleir
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2016 09:22 AM
Hi Greg,
before i give my suggession can you tell me how you are sending the notification. like what is there in when to send field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2016 10:05 AM
rushit,
Send when: "Event is fired"
Event name: "incident.state.changed"
Filter Condition- All of these conditions must be met: State is "resolved" and Close Code is not "Cancelled".
Thank you for your response!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2016 02:31 PM
Are you using the Legacy version? I'm unaware of being able to have more that once type of survey active at a time. We had to update ours to clear out any open ones if they generated a new survey w/o answering the previous.
I think what your missing is building the correct URL.
In the notification email script:
var link = new AssessmentUtils().getAssessmentInstanceURL(current.sys_id);
var url = '<a href="' + link + '">' + current.getDisplayValue("metric_type") + '</a>';
then you can print out:
template.print("We would like to invite you to participate in our Satisfaction Survey. You can access to the following link: ");
template.print(url);
For additional information: Here's how ours works.
We created a Survey + Questions
Then set up the trigger condition. (when incident is closed)
Next we created a notification to send on incident closure that calls a script:
(in the message HTML area of the notification call the email script)
${mail_script:Survey_User_Invite_script_1}
Then we create the notification script:
name: Survey_User_Invite_script_1
//Look up the assessment triggered by the incident and generate a link for the user to click.
var gr = new GlideRecord(current.getValue("trigger_table"));
gr.get(current.getValue("trigger_id")); //use this if you want to reference the ID that triggered it
var link = new AssessmentUtils().getAssessmentInstanceURL(current.sys_id);
var url = '<a href="' + link + '">' + current.getDisplayValue("metric_type") + '</a>';
var instance = "<a href='" + gs.getProperty("glide.servlet.uri") + "'>sign in</a>";
email.setSubject(gr.getValue("number") + " Closed - Survey Available."); // here we pull the incident number that triggered |
template.print("The " + gr.getClassDisplayValue() + " " + gr.getValue("number") + " has been closed.");
template.print("\n\n");
template.print("Short Description:\n" + gr.getValue("short_description"));
template.print("\n\n");
template.print("If you believe this was closed in error, or the problem persists, please call the Service Desk at ");
template.print("11-1111."); |
template.print("\n\n");
template.print("We would like to invite you to participate in our Satisfaction Survey. You can access to the following link: ");
template.print(url);
template.print("\n\n");
template.print("We appreciate your feedback and thoughtful suggestions as they help our continuous improvement initiative to provide the quality of service you expect from us.");
template.print("\n\n");
template.print("To view your survey queue at any time, " + instance + " and navigate to Self-Service > My Assessments & Surveys.");
template.print("\n\n");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 10:32 AM
Robert,
Thank you very much. Sorry it took so long to reply to this. I did end up using code as you provided however I decided to have one email go out as our "Incident Resolved" email, and then another go out as the "Take our Survey". It seems to be working well. With Geneva, it seems that multiple Survey Assessments can be created without the prior ones needing to be taken or deleted unlike in Fuji. Thanks again for your help.