How to pass more than 2 parameters to the eventQueue and access it on the notification

Hari1
Mega Sage

Hi,

I am using an eventQueue on the scheduled job and passing object as a param1.

var arrFinal = [<sys_id> of users];

 var obj = {
        iteration: iterValIncFinalVal,
        lastDate: storeValNextItr
    };

gs.eventQueue('cmp_qualifier', gr, obj, arrFinal);

I need to access both the object value of event.parm1 to be accessible on the notification subject and body.

Can this be achieved?

10 REPLIES 10

Hi,

Script looks fine and should work

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

You can use template.print('<p>Iteration : '+getParamValue.iteration+'</p>'); to print these values in email Notification body.

Hope you are receiving these values in Logs when event is triggered.

 

Thanks,
Anil Lande

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

Can we use them on the email notification subject?

Hi,

your cannot set them directly in the Subject field since you are scripting it

you can set the subject via email script using email.setSubject("My Subject");

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

How to retrieve the object in email script the below script is not working.

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

    var getParamValue = JSON.parse(event.parm1);

    gs.info("getParamValue:" + getParamValue);
    gs.info("getParamValue.iteration:" + getParamValue.iteration);
    gs.info("getParamValue.iteration:" + getParamValue.lastDate);

    email.setSubject("PI" + getParamValue.iteration + "Capacity Planning Worksheet");
	template.print('<p>Hi Team,</p><br/><p>The PI'+ getParamValue.iteration +', capacity updates via <a href="https://'+ gs.getProperty('instance_name')+'.service-now.com/sp?id=sc_cat_item&sys_id=243101531243bc5506782145e153af9a&iteration='+ getParamValue.iteration +'by COB, '+ getParamValue.iteration +'">Plan Form</a>'+ getParamValue.lastDate +'</p><br/><p>Thank you!</p>');

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

Error that i am getting in the log.

find_real_file.png

Can i use html tags in email.setBody() as that of what i have used in template.print() as per the above code.