How to store the assessment instance sys id in a variable...

robinsnow
Tera Contributor

Hi guys,

I need to send a notification with a link to a survey when incident is closed. All conditions has been set, but I need the final peace of the puzzle.

I am using a business rule that triggers the notification containing the email_scripts. In the business rule I need to define the event.parm2 and it is here I am having some trouble.

I need the sys id of the assessment instance to be added to the variable url:



var user = current.caller_id;

var gr = new GlideRecord ('asmt_assessment_instance');
gr.addQuery('task_id', current.number);
gr.query();
if(gr.next()){
    var sysid = gr.sys_id;
    var url = 'https://ossdev.service-now.com/ess?id=take_survey&instance_id='+sysid;
}

gs.eventQueue('incident.survey', current, user, url);

Somehow it is not fetching the sys_id of the instance. Any ideas?

 

Thanks guys,

Robin

1 ACCEPTED SOLUTION

Josh Virelli
Tera Guru

Hi Robin,

In your query, try using the sys_id of the task to query instead of the number. Also, I like to use getUniqueValue() instead of calling the sys_id, it's more reliable.

 

var user = current.caller_id;

var ai = new GlideRecord ('asmt_assessment_instance');
ai.addQuery('task_id', current.getUniqueValue());
ai.query();
if(ai.next()){
    var sysid = ai.getUniqueValue();
    var url = 'https://ossdev.service-now.com/ess?id=take_survey&instance_id='+sysid;
}

gs.eventQueue('incident.survey', current, user, url);

 

Let me know if that worked!

If my answer was helpful or correct, please mark it as such. 🙂

Thanks,

Josh

View solution in original post

2 REPLIES 2

Josh Virelli
Tera Guru

Hi Robin,

In your query, try using the sys_id of the task to query instead of the number. Also, I like to use getUniqueValue() instead of calling the sys_id, it's more reliable.

 

var user = current.caller_id;

var ai = new GlideRecord ('asmt_assessment_instance');
ai.addQuery('task_id', current.getUniqueValue());
ai.query();
if(ai.next()){
    var sysid = ai.getUniqueValue();
    var url = 'https://ossdev.service-now.com/ess?id=take_survey&instance_id='+sysid;
}

gs.eventQueue('incident.survey', current, user, url);

 

Let me know if that worked!

If my answer was helpful or correct, please mark it as such. 🙂

Thanks,

Josh

Josh, you are a hero! Thank you!!