
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 01:24 PM
Background:
My company has a help desk that handles incidents on a daily basis. Every incident generates a survey when the state of the incident moves to 'Resolved'. The survey created SHOULD have both a trigger_id, which is a document_id type (this is system-created) field pointing back to the original incident, AS WELL AS a task_id that is a sys_id of the incident that generated the survey.
The help desk runs a report every day on the surveys taken, the responses to those surveys, and the Resolve date (resolved_at) and Resolved Time (calendar_stc) of the incidents that generated each survey.
Problem:
The reports do not show the Resolve date and Resolve Time as they should for some incidents (they show as empty, or null). Myself and another developer managed to narrow this down to the fact that some surveys do not insert with a task_id. They DO insert with a trigger_id (so they ARE related back to the original incident), but NOT with a task_id, which is the field that the Resolve date and Resolve Time are calculated from.
(It is worth noting that this issue does not just occur with incidents, but also with requested items.)
We are positively stumped where to go from here. There is no logic on the asmt_assessment_instance table that handles populating the task_id. There is no logic on the incident table that directly touches the asmt_assessment_instance table either.
Problem Source Ideas:
There IS a trigger condition for the asmt_assessment_instance table that fires off of a business rule on the incident table, but this trigger condition is null for any surveys where the task_id is also null. So I don't think this is part of the problem.
The only possible other place I can think of would be the UI page for a survey, but I'm not sure if that would be a potential issue - or if it is, where I would look.
Any input or ideas you have to offer would be greatly appreciated. Thank you for your time.
Solved! Go to Solution.
- 3,476 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2018 05:52 AM
Update:
It turns out that the reason the task_id was not populating for some survey instances was because we have two ways a survey can be generated - either by clicking a link in an email sent after a ticket is resolved, or selecting a UI button labeled 'Send Feedback' that shows for resolved tickets on our Service Portal.
The email method of generating a survey was working fine, but the UI button was part of a widget on the service portal that did not associate the task_id with the survey it generated. The solution was to simply add a line of code to the widget so that it would associate the task_id with the survey on generation.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2018 05:52 AM
Update:
It turns out that the reason the task_id was not populating for some survey instances was because we have two ways a survey can be generated - either by clicking a link in an email sent after a ticket is resolved, or selecting a UI button labeled 'Send Feedback' that shows for resolved tickets on our Service Portal.
The email method of generating a survey was working fine, but the UI button was part of a widget on the service portal that did not associate the task_id with the survey it generated. The solution was to simply add a line of code to the widget so that it would associate the task_id with the survey on generation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 07:06 AM
Please help us with the script needs to be added to widget. It will be very very helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2019 04:47 AM
@Michael Lorincz
You mind sharing that line of code? 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2019 11:52 AM
@Balaram and @Ole,
I'm not sure how helpful this code may be, but here it is below. The key line added I have set as bold. This code was taken from the 'Send Feedback' widget, which is a UI button the user clicks when the conditions for a survey being available have been met.
assessment = (new SNC.AssessmentCreation()).createAssessments(TICKET_SURVEY, "", gs.getUserID());
assessment = assessment.split(",")
if(assessment.length >= 3){
var assessmentInstanceGR = new GlideRecord('asmt_assessment_instance');
if ( assessmentInstanceGR.get( assessment[0]) ) {
assessmentInstanceGR.trigger_table = ticket.sys_class_name;
assessmentInstanceGR.trigger_id = ticket.sys_id;
assessmentInstanceGR.task_id = ticket.sys_id;
assessmentInstanceGR.related_table_1 = 'cmn_location';
assessmentInstanceGR.update();
}
}