Wednesday, September 16, 2020

Email notification with all the variable of Catalog Item

 EMail



Notifications keep users informed of events that concern them. The system can notify users by email, SMS text message, or push notification.
Creating an email notification involves specifying when to send it, who receives it, what it contains, and if it can be delivered in an email digest.

Code:

Requested For: ${sysapproval.request.requested_for}
Cost Center to be charged: ${sysapproval.request.requested_for.cost_center}
< hr/>
< mail_script>

  var item = new GlideRecord("sc_req_item");
  item.addQuery("sys_id", current.sysapproval);
  item.query();
  if(item.next()) {

      var keys = new Array();
      var set = new GlideappVariablePoolQuestionSet();
      set.setRequestID(item.sys_id);
      set.load();
      var vs = set.getFlatQuestions();

      for (var i=0; i < vs.size(); i++) {
        if(vs.get(i).getLabel() == 'Website Cost (per year)') {
               template.print("Yearly cost for this website is " + vs.get(i).getDisplayValue() + ".\n");
        }
      }

    template.print("\nSummary of Requested item:\n\n");

     var set2 = new GlideappVariablePoolQuestionSet();
      set2.setRequestID(item.sys_id);
      set2.load();
      var vs2 = set2.getFlatQuestions();


for (var x=0; x < vs2.size(); x++) {
    if(vs2.get(x).getLabel() != '') {
        if ( vs2.get(x).getDisplayValue() != "") {
            template.space(4);
            template.print('     ' +  vs2.get(x).getLabel() + " = " + vs2.get(x).getDisplayValue() + "\n");
        }
    }
}

  }
< /mail_script>
< hr/>
${mailto:mailto.approval}
< hr/>
${mailto:mailto.rejection}
< hr/>
Approval Activity:
${mail_script:approval_activity}
< hr />
Click here to view Approval Request: ${URI}
Click here to view ${sysapproval.sys_class_name}:  ${sysapproval.URI}

No comments:

Post a Comment