The CreatorCon Call for Content is officially open! Get started here.

Survey is showing undefined

nameisnani
Mega Sage

Hi Team ,

 

while clicking on the emoji , coming as undefind 

nameisnani_0-1705640202798.pngnameisnani_1-1705640294778.png

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


    gs.log("current " + current.number, 'sys');

    var surv = new GlideRecord('asmt_assessment_instance');
    surv.addNotNullQuery('trigger_id');
    surv.addQuery('trigger_id', current.sys_id);
    surv.query();
    surv.next();
    gs.log("Incident from survey " + surv.number, 'sys');

    var params = current.number + "," + surv.number;
    //var subject = "survey:" + surv.number + " " + " " + "incident:" + current.number + " ";
    var subject = "Reminder:Please share your feedback on " + "Incident: " + current.number;
    //+ " " + ": Survey Number : " + surv.number;
    email.setSubject(subject);



    template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/sp?id=take_survey&instance_id=' + surv.sys_id + '"><img src="CSAT.png" width="280" height="55"/></a>');





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

 

This is the email script , what will be error can anyone please help me here .

How to sort it out .

@Anil Lande 

 

Thanks in adavance 

1 ACCEPTED SOLUTION

Hi @nameisnani ,

I believe same script was shared on another thread and that resolved your issue.

Could you please close this question by marking appropriate solutions as correct answers?

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

20 REPLIES 20

Anil Lande
Kilo Patron

Hi @nameisnani ,

Please try this:

 

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

    gs.log("current " + current.number, 'sys');
    var surv = new GlideRecord('asmt_assessment_instance');
    surv.addNotNullQuery('trigger_id');
    surv.addQuery('trigger_id', current.sys_id);
    surv.query();
    surv.next();
if(surv.next()){ 
    gs.log("Incident from survey " + surv.number, 'sys');
    var params = current.number + "," + surv.number;
    //var subject = "survey:" + surv.number + " " + " " + "incident:" + current.number + " ";
    var subject = "Reminder:Please share your feedback on " + "Incident: " + current.number;
    //+ " " + ": Survey Number : " + surv.number;
    email.setSubject(subject);

    template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/sp?id=take_survey&instance_id=' + surv.sys_id + '"><img src="CSAT.png" width="280" height="55"/></a>');
}

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

 

 

You have not used surv.next() after query() statement to read GlideRecord data.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thanks for Your response @Anil Lande  let me try once

Hi @Anil Lande  

 

After updating your script , emjois and subjiect is not coming

 

nameisnani_0-1705647647161.png

nameisnani_1-1705647701393.png

 

@Anil Lande  could you please suggest what need to do here 

 

Can you please share more details?

on which table you have created this notification?

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande