Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get Assessment Metric Image Attachment in Email Notification Script?

danielgeorg
Tera Contributor

Hello,

 

I am trying to get the attached assessment metric images within asmt_metric_list.

The usecase is that a user fills out a survey after their ticket has been closed. They can select a variety of image emojis describing how they feel. I would like to grab those emojis and send them as an email to the person who was assigned to said ticket.

 

My current script:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
    var glideRecord = new GlideRecord("asmt_assessment_instance_question");
    glideRecord.addQuery("instance", "=", current.sys_id);
    glideRecord.orderBy("name");
    glideRecord.query();

    while (glideRecord.next()) {
        var getImage = new GlideRecord("asmt_metric_definition");
        getImage.get(glideRecord.metric);
        template.print(getImage.getDisplayValue());
        template.print("<img src=/sys_attachment.do?sys_id=" + glideRecord.metric + ">");
    }
})(current, template, email, email_action, event);
 
The img src should point towards the selected image for each metric. However, right now, metric points to null because it is an image type.
What am I doing wrong and how do I get the URL/sys_id for each metric?
0 REPLIES 0