Inbound Action not setting correct target record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 07:01 AM
Hello Guru's:
I have a requirement to create an Interaction record if the user replies to a CLOSED/Inactive ticket.
I was able to get the script to create the new IMS ticket. YEAH!!!
However, the target record for the received email isn't setting to the IMS ticket, on the the Table Reference Old ticket.
E.G.
Caller responds to ticket INC001 or RITM0001 which is closed/inactive.
The inbound script sets the received email to INC001/RITM001 depending the watermark.
Having read some of the prior posts on Inbound Actions, it would appear that this is an OOB feature.
Does anyone have a way to override this?
I've tried setting up a GlideRecord lookup after inserting the new record (and also without it) but it's not working.
(function runAction(current, event, email, logger, classifier) {
gs.include('validators');
if (current.getTableName() == "sc_req_item" && current.active==false) {
var reply = "reply from: " + email.origemail + "\n\n" + email.body_text;
var sysNum = sys_email.sys_id ;
var subject = email.subject.toLowerCase();
// Current RITM is closed - Create a new Interaction
var rtm = new GlideRecord('interaction');
rtm.initialize();
rtm.short_description = 'Opened new interaction from ticket: ' + current.number;
rtm.u_description = 'The above ticket was created to re-check the following ticket : ' + current.number + "\n\n" + email.body_text + '\n\n' + 'Original Description : ' + current.description;
rtm.priority = current.priority;
// User search and fill in requester and opened by
var sid = gs.createUser(email.from);
var usEmail = new GlideRecord('sys_user');
usEmail.addQuery('sys_id',sid);
usEmail.query();
if(usEmail.next()){
rtm.u_entity = usEmail.u_entity;
}
rtm.opened_for = sid;
rtm.opened_by = sid;
rtm.company = current.company;
rtm.u_originial_email = sysNum;
if(usEmail.u_entity == 'fd290f06db709f047317323b7c961912'){
rtm.assignment_group = '51e79072dbb507001e28dbbb5e9619d6';//PL - AppSupport
}else{
rtm.assignment_group = 'aa9be604dbd76b000d95561bdc96199d';//HTH - ServiceDesk
}
rtm.contact_type = "email";
rtm.insert();
gs.info('eric - the ticket number is '+rtm.number);
//current.work_notes = 'Opened new call from email. The newcall number is : ' + inc.number;
var updEmail = new GlideRecord('interaction');
updEmail.addQuery('sys+id',rtm.sys_id);
updEmail.query();
if(updEmail.next()){
current.mailbox='received';//received
current.target = rtm.sys_id;
current.target_table = 'interaction';
current.update();
}
}
})(current, event, email, logger, classifier);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 07:12 AM
Hi
to be honest, I don't know whether it is possible what you want to achieve, as ServiceNow tries to assign an email to the target record based on the watermark.
But I found an error in your script and maybe the fix can make your script working. Instead of
updEmail.addQuery('sys+id',rtm.sys_id);
write
updEmail.addQuery('sys_id',rtm.sys_id);
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 07:16 AM
Thanks. I missed that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 07:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 09:40 AM
I've tried but can find a way to get the Ref:MSG######## out of the body text.
I look at similar posts in community and have seen either that the parsing functionality is not there yet or not able to load the " Parse Email Body Text Flow Action" that was found in the developers share.
Do you any further suggestions?