Inbound action to update Assessments

Kumar96
Kilo Contributor

HI

 

I am developing a smiley survey response. I am using surveys and assessments to do the same.

 

The survey is sent and the user receives the emails like this.  User clicks on a image and an inbound action is triggered to update the assessment

find_real_file.png

 

It is working as designed but the assessment data is not complete.  Below is my code for inbound action

var gr = new GlideRecord("asmt_metric_result");
gr.initialize();
gr.instance = current.sys_id;
gr.source_id = '0da79929db086b04c296d7795e9619f7';
gr.actual_value = resp;
gr.string_value = stringValue;
gr.datatype = 'imagescale';
gr.assessment_group = current.assessment_group;
gr.user = current.user;
gr.taken_on = gs.nowDateTime();
gr.metric = current.metric;
gr.insert();

current.state = 'complete';

current.update();

 

The data that is updated is like this.  the survey has 2 questions.  It is not updating the actual values and the string values .

 

Am I missing something. Can any one help me in this

 

find_real_file.png

5 REPLIES 5

Allen Andreas
Administrator
Administrator

Hi,

Have you checked the sys_email.list for this incoming email to see that it was received by your system and then look to see what happened? Is anything getting updated? Within that email log it'll tell you if the task/record was updated or not. You're saying working as expected, but in what regard?


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

The email logs show that the record has been updated.

Also when I look at the asmt_metric_result table I see 3 records for the Assessment instance

Infact it has to create 3 records because I have given 2 questions on the survey and one instance record

The instance record does not have any data in it except actual value and string value.

 

 

find_real_file.png

Do you have a screenshot or something of the actual email sent and/or what is coming back from in their email? Like are you using a mailto script to have it shoot back a 5 or something when they click on the happy face? is the current state being changed to complete like in your script?

Basically just trying to see if ANYTHING is coming through, or just a few pieces of information.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

The email that goes to the user

 

find_real_file.png

Sample Mail Script 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {

// Add your code here

var img = "/ExtremelySatisfied.png";
var response = "Very Satisfied";
template.print(renderMailtoButton(img, response,current.number));

})(current, template, email, email_action, event);

 

Script Include

 

function renderMailtoButton(image, response,Assessmentnumber){

var instance = gs.getProperty("instance_name");
var link = "https://" + instance + ".service-now.com";
var mark = email.watermark;
var number = '';
var emailAddress = instance + "@service-now.com";
//Different number if from an approval
if (current.getTableName().indexOf("asmt_assessment_instance") != -1){
number = Assessmentnumber;
}
var mailLink = '<a href="mailto:'+ emailAddress + '?subject= Re:' + number + ' ' + response +'&body=%0A%0A' + mark + '"><img src="' + link + image + '" width="100" height="100"></a>';
return mailLink;
}

 

Hope this helps