How to add catalog item variables to a custom email that i want to send to a group of users after my request is approved.

abcmh
Giga Contributor

I have a catalog item that as a workflow associated with it. Once the request is approved by the approvers, an email notification needs to be sent out to a group of users.

This email should contain the request details as it is being sent to users who are external to the organization. So i cannot send them a link to the catalog item record .

So i want to populate the email body with the variables from the request.


So i have created a Email Template, Notification and an event which is fired after the request is approved.

I want to a mail script that will let me include the variables to the body of the email that will be sent out.

I tried to add a mail script but i wasn't able to link it to the Template or call it anywhere in the notification or template.

Any suggestions?

Thanks..

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

All the mailscripts are stored in notification email script module. You can print the variables in format current.variables.variable_name as shown below



find_real_file.png



Then you can call email script from notification using below format



find_real_file.png



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

6 REPLIES 6

Harsh Vardhan
Giga Patron

Hi Amol,



Please check the thread below.



Customize Approval Request notification



Thanks,


Harshvardhan


Alikutty A
Tera Sage

Hi Amol,



I doubt if you can add a mail script in an email template. You will have to add the mail script directly on the notification message HTML field as



${mail_script:script name}



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


SanjivMeher
Kilo Patron
Kilo Patron

All the mailscripts are stored in notification email script module. You can print the variables in format current.variables.variable_name as shown below



find_real_file.png



Then you can call email script from notification using below format



find_real_file.png



Please mark this response as correct or helpful if it assisted you with your question.

Sanjiv,




Thanks for your input. The script below seems to be working but prints everything in a single paragraph.



template.print("<p></p>Requested items:\n");



  var gr = new GlideRecord("sc_req_item");


  gr.addQuery("request", current.sys_id);


  gr.query();


  //while(gr.next()) {


      //template.print(gr.number + ":   " + gr.cat_item.getDisplayValue() + ", Stage: " + gr.stage.getDisplayValue() + "\n");



//       template.print("Request number:   " + gr.request.number   + "\n");


  if (current.cat_item.name.indexOf('Corporate Real Estate V2') > -1)


    {


   


    template.print('\n'+"Indicate Group:     "+ current.variables.Indicate_Group   + "\n");


  if (current.variables.CRE_BC_BP != false)


  {


   


    template.print('\n'+"Project Driver:   " + "Business Process"   + "\n");


    }


  if (current.variables.CRE_BC_NewContract != false)


      {


        template.print('\n'+"Project Driver:   " + current.variables.CRE_BC_NewContract + "\n");


      }


    if (current.variables.CRE_BC_ChginContract != false)


    {


    template.print('\n'+"Project Driver:   " + current.variables.CRE_BC_ChginContract + "\n");


    }


    if (current.variables.CRE_BC_Reorg != false)


    {


    template.print('\n'+"Project Driver:   " + current.variables.CRE_BC_Reorg   + "\n");


    }


    if (current.variables.CRE_BC_Other != false)


    {


    template.print('\n'+"Project Driver:   " + current.variables.CRE_BC_Other   + "\n");


    }


   


            }