How to set Target field in Email Log?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 11:52 PM
Hi All,
I am replying to an Email into Servicenow. However, the ticket is created but the Target field is blank.
Any help is highly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 12:06 AM
Hi,
please share your Script which you have written in inbound Email; action.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 01:50 AM
Target Table : Change Request
Action type : Record Action
var from = email.from;
var from_id = new GlideRecord('sys_user');
from_id.addQuery('email',from);
from_id.addQuery('active',true);
from_id.query();
if(from_id.getRowCount() > 0){
var approvalStatus = email.body;
var approvalStatus1 = email.body.status;
if(approvalStatus1 =='Yes' || approvalStatus1 == "OK" || approvalStatus == "ACCEPT" || approvalStatus == "APPROVE" || approvalStatus == "GOAHEAD" || approvalStatus == "APPROVED"){
var cr = new GlideRecord('sysapproval_approver');
cr.addQuery('document_id',current.sys_id);
cr.query();
if(cr.next()){
cr.state = 'approved';
cr.update();
}
}
if(approvalStatus == "NO" || approvalStatus == "CANCEL" || approvalStatus == "REJECT" || approvalStatus == "NOGO" || approvalStatus == "NOT APPROVED" || approvalStatus == "DIS APPROVED" || approvalStatus == "REFUSED")
{
var cr1 = new GlideRecord('sysapproval_approver');
cr1.addQuery('document_id',current.sys_id);
cr1.query();
if(cr1.next())
cr1.state = 'rejected';
cr1.update();
}
}
else{
var em2 = new GlideRecord('sys_email');
em2.initialize();
em2.mailbox = 'outbox';
em2.state = 'ready';
em2.type = 'send-ready';
em2.user = from;
em2.recipients = from;
em2.subject = "Auto-reply: Customer ID and PIN are incorrect";
em2.body = "Dear Customer, Approval Status is not in accepted format!";
em2.insert();
}
})(current, event, email, logger, classifier);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 02:01 AM
Hi,
it seems that you are not assigning any value to your targate record,
first tell me what is your expected output?
meanwhile you can check Update Change OOB Email Inbound Action.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 03:46 AM
The State field in sysapproval_approver should be set to Approved/Rejected based on the the values mentioned in the email body.
For eg: If i mention Yes, the State should change to Approved and if i select NO, the State should change to Rejected.