Attachment not attached to target table
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 05:59 AM
Hi Team,
Attachment is not getting attached to target table. When vendor replies with document attached it doesn't attach to target HR case.
This happens intermittently. Also action and action reason is not populated.
Inbound script:
/**Case Status : 3- Closed, 24- Pending, 18- Work In Progress, 20- Resolved **/
gs.include('validators');
if (current.state != 3) {
if (current.state == 24 || email.subject.startsWith("Re: Reopen"))
current.state = '18';
else if (current.state == 20) {
var fromglintinc = email.origemail == 'test@gmail.com';
var frominsurestreet = email.origemail == 'Test@gmail.com';
var isfeedbackfromglint = String(email.body_text).indexOf('How would you rate the support you received?') != -1;
if (fromglintinc && isfeedbackfromglint || frominsurestreet && isfeedbackfromglint) { //STRY3254641
gs.eventQueue('sn_hr_core.hr.email.rejected_external', current, email.origemail, gs.getUserName());
} else if (String(email.body_text).indexOf('Check the resolution of your case at') == -1) {
current.state = '18';
} else
gs.eventQueue('sn_hr_core.hr.email.rejected_external', current, email.origemail, gs.getUserName());
}
if (email.from_sys_id == current.opened_for)
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
else
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
} else if (current.state == 3 && current.transferred_to != '') {
// if the case is transferred, we need to add the comments to latest transferred to case
var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('u_ps_number=' + current.u_ps_number + '^transferred_to=NULL');
gr.query();
if (gr.next()) {
//transferred to case also closed, so let's send the reject email to user
if (gr.state == 3) {
gs.eventQueue('sn_hr_core.hr.email.rejected', gr, email.origemail, gs.getUserName());
} else {
//transferred to case is open, so let's add the comments
if (gr.state == 24 || email.subject.startsWith("Re: Reopen"))
gr.state = '18';
else if (gr.state == 20) {
if (String(email.body_text).indexOf('Check the resolution of your case at') == -1)
gr.state = '18';
else
gs.eventQueue('sn_hr_core.hr.email.rejected_external', gr, email.origemail, gs.getUserName());
}
if (email.from_sys_id == gr.opened_for)
gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
else
gr.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
gr.update();
}
}
} else if (current.state == 3 && current.transferred_to == '') {
//case is closed and it is not transferred, so let's send reject email
gs.eventQueue('sn_hr_core.hr.email.rejected', current, email.origemail, gs.getUserName());
}
Any suggestion please
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 06:44 AM
Did you check the file size is large and crossing the limit defined within the instance?
Did you check the file extension is allowed?
there is no line of code for adding attachment.
Did you check how it gets added?
try adding this in your script
gs.include('validators');
if (current.state != 3) {
if (current.state == 24 || email.subject.startsWith("Re: Reopen"))
current.state = '18';
else if (current.state == 20) {
var fromglintinc = email.origemail == 'test@gmail.com';
var frominsurestreet = email.origemail == 'Test@gmail.com';
var isfeedbackfromglint = String(email.body_text).indexOf('How would you rate the support you received?') != -1;
if (fromglintinc && isfeedbackfromglint || frominsurestreet && isfeedbackfromglint) { //STRY3254641
gs.eventQueue('sn_hr_core.hr.email.rejected_external', current, email.origemail, gs.getUserName());
} else if (String(email.body_text).indexOf('Check the resolution of your case at') == -1) {
current.state = '18';
} else
gs.eventQueue('sn_hr_core.hr.email.rejected_external', current, email.origemail, gs.getUserName());
}
if (email.from_sys_id == current.opened_for)
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
else
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
GlideSysAttachment.copy('sys_email', sys_email.sys_id, current.getTableName(), current.sys_id);
current.update();
} else if (current.state == 3 && current.transferred_to != '') {
// if the case is transferred, we need to add the comments to latest transferred to case
var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('u_ps_number=' + current.u_ps_number + '^transferred_to=NULL');
gr.query();
if (gr.next()) {
//transferred to case also closed, so let's send the reject email to user
if (gr.state == 3) {
gs.eventQueue('sn_hr_core.hr.email.rejected', gr, email.origemail, gs.getUserName());
} else {
//transferred to case is open, so let's add the comments
if (gr.state == 24 || email.subject.startsWith("Re: Reopen"))
gr.state = '18';
else if (gr.state == 20) {
if (String(email.body_text).indexOf('Check the resolution of your case at') == -1)
gr.state = '18';
else
gs.eventQueue('sn_hr_core.hr.email.rejected_external', gr, email.origemail, gs.getUserName());
}
if (email.from_sys_id == gr.opened_for)
gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
else
gr.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
gr.update();
GlideSysAttachment.copy('sys_email', sys_email.sys_id, gr.getTableName(), gr.sys_id);
}
}
} else if (current.state == 3 && current.transferred_to == '') {
//case is closed and it is not transferred, so let's send reject email
gs.eventQueue('sn_hr_core.hr.email.rejected', current, email.origemail, gs.getUserName());
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader