|
| 1 | +(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, |
| 2 | +/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, |
| 3 | +/* Optional GlideRecord */ event) { |
| 4 | + |
| 5 | + var requestId = current; |
| 6 | + var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix(); |
| 7 | + var requestUrl = '/' + portalSuffix + '?id=order_status&table=sc_request&sys_id=' + current.sys_id.toString(); |
| 8 | + var fontSize = 'font-size: 16px;'; |
| 9 | + var lineHeight = 'line-height: 24px;'; |
| 10 | + var notificationUtil = new RequestNotificationUtil(); |
| 11 | + |
| 12 | + var requestDetails = notificationUtil.getRequestDetails(current.sys_id, current); |
| 13 | + var tasks = requestDetails.tasks; |
| 14 | + var totalTasks = requestDetails.totalTasks; |
| 15 | + |
| 16 | + notificationUtil.createNotificationPrimayAction(template, requestUrl, 'View request'); |
| 17 | + template.print('<div style="font-size: 15pt; line-height:30px;"><b>About this request</b></div>'); |
| 18 | + |
| 19 | + var commentLeft = notificationUtil.getRequestComment(current.sys_id, current.approval); |
| 20 | + if (commentLeft) { |
| 21 | + template.print('<div style="padding-top: 16px; ' + fontSize + lineHeight + '"><span>Rejection notes: </span>' + '<span style="font-weight: 600;">' + commentLeft + '</span></div>'); |
| 22 | + } |
| 23 | + //For reject comments added to RITM record |
| 24 | + var commentLeftRITM = notificationUtil.getRejectCommentRITM(current.sys_id); |
| 25 | + if (commentLeftRITM) { |
| 26 | + template.print('<div style="padding-top:18px; ' + fontSize + lineHeight + '"><span>Rejection notes: </span>' + '<span style="font-weight: 600;">' + commentLeftRITM + '</span></div><br />'); |
| 27 | + } |
| 28 | + if (requestDetails.totalTasks > 1) { |
| 29 | + template.print('<div style="font-size: 15pt;padding-top:16px;font-weight:600;">Requested items (' + requestDetails.totalTasks + ')</div>'); |
| 30 | + } |
| 31 | + tasks.forEach(function (task, index) { |
| 32 | + var borderBottom = 'border-bottom:1px solid #DADDE2'; |
| 33 | + template.print('<div style="padding-top:16px;padding-bottom:16px;'); |
| 34 | + if (requestDetails.totalTasks > requestDetails.tasks.length || (index + 1 < requestDetails.tasks.length)) { |
| 35 | + template.print(borderBottom); |
| 36 | + } |
| 37 | + template.print('">'); |
| 38 | + template.print('<div style="' + fontSize + lineHeight + '"><span>Requested item number:</span> <span style="font-weight: 600;">' + task.requestNumber + '</span></div>'); |
| 39 | + template.print('<div style="' + fontSize + lineHeight + '"><span>Short description: </span><span style="font-weight: 600;">' + task.item + '</span></div>'); |
| 40 | + template.print('</div>'); |
| 41 | + }); |
| 42 | + |
| 43 | + if (totalTasks > 3) { |
| 44 | + template.print('<div style="' + fontSize + lineHeight + 'padding-top:16px; padding-bottom:16px;"><a style="color:#3C59E7" href="' + requestUrl + '">'); |
| 45 | + template.print(gs.getMessage('View all items')); |
| 46 | + template.print('</a></div>'); |
| 47 | + } |
| 48 | +})(current, template, email, email_action, event); |
0 commit comments