Can someone help me how to send notification to the manager from email inbound action.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 04:28 AM
Is it possible to achieve this? We have an email inbound action from Workday. Once we receive an email it triggers requests and keeps the requested by as "Workday" We need to change this to the Manager's name. So Requested by will be the Manager and requested for will be the user.
Please find the below inbound action code for reference.
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
//if (email.subject.toLowerCase().indexOf("is terming, effective") >= 0){
if ((email.subject.toLowerCase().indexOf("is terming, effective") >= 0)||(email.subject.toLowerCase().indexOf("termination") >= 0))
{
//User Account Intake
var cart = new Cart();
var item = cart.addItem('bf36728a1bd5cc106d1dda83cd4bcb24'); //User Account Intake
cart.setVariable(item, 'type_of_request', 'Terminate User');
//set requested_for as name from email subject
var subject = email.subject.toString();
//var nameOnly = subject.substr(0, subject.indexOf('is terming, effective'));
var nameOnly = (subject.substr(0, subject.indexOf('is terming, effective'))||subject.substr(0, subject.indexOf('termination')));
var usr = new GlideRecord('sys_user');
usr.addQuery('name',nameOnly);
usr.query();
if (usr.next()){
var uid = usr.sys_id;
}
cart.setVariable(item, 'requested_for', uid);
var manUsr = new GlideRecord('sys_user');
manUsr.addQuery('name', email.body.manager);
manUsr.query();
if( manUsr.next() ){
var manager = manUsr.sys_id;
}
//set date in catalog item from effective date in email
var term = email.body.effective_date;
var year = term.substring(6, 10);
var month = term.substring(0, 2);
var day = term.substring(3, 5);
var date = year + '-' + month + '-' + day;
var gd = new GlideDate();
var comments = JSON.stringify(email.body,null, 2);
gd.setValue(date);
cart.setVariable(item, 'term_date', gd);
cart.setVariable(item, 'position_title', email.body.job_title);
cart.setVariable(item, 'additional_comments', comments.toString());
cart.setVariable(item, 'manager', manager);
cart.placeOrder();
}
})(current, event, email, logger, classifier);
Regards,
Naganandini N
0 REPLIES 0