email script

nameisnani
Mega Sage

Hi Team , 

 

can anyone please help me in the , mail script 

 

I want print for a specific catalog item variables in the notification .

 

i have written mail script for this 

nameisnani_0-1718851759489.png

 

Please correct if there is any mistake in notification configuration 

nameisnani_1-1718851827091.png

nameisnani_2-1718851894335.png

 

Preview is showing like this 

nameisnani_3-1718852051220.png

 

Catalog Item variables 

nameisnani_4-1718852178025.png

 

 

 

OUTPUT has to come like this 

 

SUB :- Short desciption 

 

Body

"A lost or stolen device has been reported by" <Requested For>
The device was lost or stolen on <Date item was Lost/Stolen>
[Blank Line]
"Description:"
<Description>

 

 

can anyone please help me here .

 

what was the mistake .

 

thanks

8 REPLIES 8

nameisnani
Mega Sage

@SN_Learn 

 

I am confused here , could you please help me here , complete script .... please provide script to me 

The notification email script:

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

    var requester = current.requested_for.getDisplayValue();
    var date = current.variables.date_item_was_stolen.getDisplayValue();

    email.setSubject(current.short_description);
    template.print("<p>A lost or stolen device has been reported by " + requester);
    template.print("<p>The device was lost or stolen on " + date);
    template.print("<br />");
    template.print("Description:" + current.description);



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

 

Mark this as Helpful / Accept the Solution if this clears your issue

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

nameisnani
Mega Sage

@SN_Learn @dhanrajb 

 

still error is coming 

 

nameisnani_0-1718860333381.png

 

Date is not coming 

 

The short desp and desp we are getting from Variable set 

 

nameisnani_1-1718860400661.png

 

 

can you please help here @SN_Learn @dhanrajb 

Try the updated code:

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

    var requester = current.requested_for.getDisplayValue();
    var date = current.variables.date_item_was_lost_stolen.getDisplayValue();

    email.setSubject(current.variables.short_description_1);
    template.print("<p>A lost or stolen device has been reported by " + requester);
    template.print("<p>The device was lost or stolen on " + date);
    template.print("<br />");
    template.print("Description:" + current.variables.description_1);


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

 

Mark this as Helpful / Accept the Solution if this clears your issue

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.