Request was opened notification

dustinjones
Tera Expert

Hello,

 

I would like to add more info to the "Request was opened" OOB notification. The notification is on the sc_request table and seems like all the information is on the sc_req_item table. I looked at potentially adding a notification script that looks at the sc_req_item table but having never done this before wasn't sure where to start. All I want is the notification to include the short description from the RITM if possible.

 

Thanks

1 ACCEPTED SOLUTION

sushantmalsure
Mega Sage

OK here you can start with.

Step 1: open notification and add mailscript like in following screenshot:

sushantmalsure_0-1689806072951.png

 

In this step we have added a mail script of name 'getRITMDetails'.

 

Step 2: Create mail script of name 'getRITMDetails' under system notifications > Notification Email Script > create new

it should look like this:

sushantmalsure_1-1689806213535.png

 

script:

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

    // Add your code here\
    var getRITM = new GlideRecord('sc_req_item');
    getRITM.addQuery('request', current.sys_id);
    getRITM.query();
    if (getRITM.next()) {
        template.print('<div style="font-size: 15pt; line-height:30px; padding-bottom:16px"><b style="font-weight:600">The short description from RITM is ' + getRITM.short_description +'</b></div>');
    }

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

 

In this step we have added a mail script and if you see on line number 12, template.print() is the method which will be writing the short description along with text specified.

Now you can add more field details from sc_req_item just like this using template.print() method.

 

Once you are done test it 🙂

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

View solution in original post

3 REPLIES 3

sushantmalsure
Mega Sage

OK here you can start with.

Step 1: open notification and add mailscript like in following screenshot:

sushantmalsure_0-1689806072951.png

 

In this step we have added a mail script of name 'getRITMDetails'.

 

Step 2: Create mail script of name 'getRITMDetails' under system notifications > Notification Email Script > create new

it should look like this:

sushantmalsure_1-1689806213535.png

 

script:

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

    // Add your code here\
    var getRITM = new GlideRecord('sc_req_item');
    getRITM.addQuery('request', current.sys_id);
    getRITM.query();
    if (getRITM.next()) {
        template.print('<div style="font-size: 15pt; line-height:30px; padding-bottom:16px"><b style="font-weight:600">The short description from RITM is ' + getRITM.short_description +'</b></div>');
    }

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

 

In this step we have added a mail script and if you see on line number 12, template.print() is the method which will be writing the short description along with text specified.

Now you can add more field details from sc_req_item just like this using template.print() method.

 

Once you are done test it 🙂

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

This was 100% what I wanted. Thank you!

sushantmalsure
Mega Sage

.. @dustinjones 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure