- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 11:45 AM
Hi ,
Can someone please help me to fix the below inbound mail script code.
Below code is written to verify whether the inbound email has attachments or not.If there are attachments then we have to setValue on a task and trigger an event. If not we have to abort the whole setValue action and trigger an event which sends an email notification . But both if(attachLog.next()) and else code parts are executing all the time. Instead of either one of the events both events are being triggered.
if (email.subject.contains("accept")) {
/var email_log = new GlideRecord('sys_email');
email_log.addQuery('uid', email.uid);
email_log.query();
if (email_log.next()) {
var attachLog = new GlideRecord('sys_attachment');
attachLog.addQuery('table_sys_id', email_log.sys_id);
attachLog.addQuery('table', 'sys_email');
attachLog.query();
if (attachLog.next()) {
current.setValue("u_response"," accepted");
gs.info("In the inbound email action before triggering event");
gs.eventQueue('letter_response',current);
}
else{
gs.info("In the inbound email action before triggering event");
gs.eventQueue('letter_response_attachdocs',current);
}
}
}
Solved! Go to Solution.
- 2,719 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2019 07:39 AM
I figured out what's wrong with the code attachLog.addQuery('table', 'sys_email'); the field name table in the query statement is what giving me the trouble , as it should be attachLog.addQuery('table_name', 'sys_email');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2018 06:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2019 06:08 PM
There is no loop in the code emailLog.next() and attachLog.next() both are if conditions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2019 09:02 PM
I'm assuming the single "/" in the second line of code is a typo and not really there in your Inbound Email Action, correct? Is that the entire contents of the script?
And both of your "gs.info" calls are outputting the same string, so that may not be helping your debugging.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2019 05:17 AM
That " / " is just a typo and the event "gs.eventQueue('letter_response_attachdocs',current)" in the else part will trigger a email notification. I am still receiving that email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2019 07:39 AM
I figured out what's wrong with the code attachLog.addQuery('table', 'sys_email'); the field name table in the query statement is what giving me the trouble , as it should be attachLog.addQuery('table_name', 'sys_email');