The CreatorCon Call for Content is officially open! Get started here.

Show RITM number in subject

Gillerla Rajesh
Tera Contributor

Notification written in req table and customer need to RITM number in subject line 

If single Req has multiple RITM means i need to show all RITM numbers in subject

 

 

Any one help on this, I think I will go for email script but I need any sample script.

1 ACCEPTED SOLUTION

Robin John
Kilo Sage

The script is pretty straightforward. Assuming that the request GR is contained in the "current" variable:

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

    var requestedItems = [];

    // Create a new GlideRecord for the 'sc_req_item' table
    var requestedItemGR = new GlideRecord('sc_req_item');

    // Query for requested items related to the current request
    requestedItemGR.addQuery('request', current.getValue('sys_id'));
    requestedItemGR.query();
    while (requestedItemGR.next()) {
        requestedItems.push(requestedItemGR.number.toString());
    }
    var subject = 'Requested Items Numbers: ' + requestedItems.join(', ');

    // Set the subject for the email
    email.setSubject(subject);

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

 Create a Notification Email Script and add it in the body of the notification. The "email.SetSubject()" is the part which will set the email subject. You can format the string argument as you desire.

View solution in original post

5 REPLIES 5

  requestedItemGR.addQuery('request', current.getValue('sys_id'))

 

Here how it will pic current sys_id

 

Here we not given any table right, if in Business rule mean i have have table is current based on table it will pic sys_id

 

But here in email script how it will pic , can pls explain me