- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 06:15 AM
When using new SNC.AssessmentCreation()).createAssessments, how do you associate the newly created survey with a task record? For example, an incident, change request, etc, like happens when you use the trigger.
I can associate it with a record if you use sn_assessment_core.AssessmentCreation()).conditionTrigger, but then you have to use the "opened by" or "assigned to" user field that is configured in the trigger.
SNC.AssessmentCreation()).createAssessments
For above function, I can create surveys and assign them to a user of my choosing in the script. However, there is no option to tie it to a task record like change request.
sn_assessment_core.AssessmentCreation()).conditionTrigger
For this above function, I can create surveys that are tied to a task record like change request, but I have to assign the survey to the user record that is in the trigger.
I was hoping I could do something like SNC.AssessmentCreation()).createAssessments but tie it to a task record like incident or change.
I hope that makes sense.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 06:59 AM
Hi,
The createAssessments returns a sysId of the assessment/survey and/or the groupId.
See for details how the result looks like at:
When you have the assessment instanceId, you can link the record(task) via script. Something like:
function getInstanceId(userId) {
//generate the instance for this instance and return the sys_id
var assessmentId = 'YouAssessmentId'; //sys_id of the survey/assessment
var result = new global.AssessmentUtils().createAssessments(assessmentId, '', userId);
result = result.split(',');
var instanceId = result[0];
grInstance = new GlideRecord('asmt_assessment_instance');
if (grInstance.get(instanceId)){
grInstance.setValue('task_id', current.getUniqueValue());
grInstance.setValue('trigger_id', current.getUniqueValue());
grInstance.setValue('trigger_table', current.getTableName());
grInstance.update();
}
return instanceId;
}
Regards,
Hayo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 06:59 AM
Hi,
The createAssessments returns a sysId of the assessment/survey and/or the groupId.
See for details how the result looks like at:
When you have the assessment instanceId, you can link the record(task) via script. Something like:
function getInstanceId(userId) {
//generate the instance for this instance and return the sys_id
var assessmentId = 'YouAssessmentId'; //sys_id of the survey/assessment
var result = new global.AssessmentUtils().createAssessments(assessmentId, '', userId);
result = result.split(',');
var instanceId = result[0];
grInstance = new GlideRecord('asmt_assessment_instance');
if (grInstance.get(instanceId)){
grInstance.setValue('task_id', current.getUniqueValue());
grInstance.setValue('trigger_id', current.getUniqueValue());
grInstance.setValue('trigger_table', current.getTableName());
grInstance.update();
}
return instanceId;
}
Regards,
Hayo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:11 PM
I was able to get it to work. Thanks so much for your help on this. I was able to set a result variable to capture the instanceId to use to update the task, trigger, table information. That was exactly what I needed.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 08:43 AM
Hi @Tim34 ,
How are you sending the survey notification link ? Can you please share me all the steps you did to make it work ?
Thanks a lot 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 10:43 AM
Hi Gpope, the survey notification link is sent out by a Notification that I setup based on certain conditions. You can define who to send it to and under what conditions. The email sent contains the survey link.
Is there anything specific you wanted to know?