- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 09:28 PM - edited ‎01-18-2024 09:29 PM
Hello Everyone,
I have an Inbound Script that creates a ticket when an email is sent to a specific email address.
Now, I would like to add a functionality: if the email contains an attachment and the attachment is a MP3, the priority must change.
I wondered if it would be better to set it up in the Inbound Script or a separate Business Rule:
This is a Business Rule I found and tried to modified, but it is not working
(function executeRule(current, previous /*null when async*/) {
// Check if the current record is an Incident record and has attachments
if (current.getTableName() === 'incident' && current.attachment_guid) {
// Retrieve attachment details
var attachments = new GlideSysAttachment().get(current.attachment_guid);
// Loop through attachments
for (var i = 0; i < attachments.size(); i++) {
// Check if the attachment has an MP3 extension
if (attachments.get(i).file_name.endsWith('.mp3')) {
// Set the contact_method field to "phone"
current.contact_method = 'phone';
// Additional logic or actions can be added here if needed
// Break out of the loop since we found an MP3 attachment
break;
}
}
}
})(current, previous);
Any assistance would be appreciated.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 06:08 AM
So, I used the following script, and it WORKED!!!
but I cannot get it working when I had 2 extensions Mp3 and Wav, it only works with Wav
Any suggestions?
(function executeRule(current, previous /*null when async*/) {
// Check if the record has attachments with the extension MP3
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_sys_id', current.sys_id);
attachmentGR.addQuery('file_name', 'LIKE', '%.wav');
attachmentGR.query();
if (attachmentGR.next()) {
// If attachments with MP3 extension found, change contact_method to EMAIL
current.contact_method = 'Phone';
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 09:42 PM
Hi @AngelP83 I think there is an error in the below line
if (attachments.get(i).file_name.endsWith('.mp3')) {
to
if (attachments[i].file_name.endsWith('.mp3')) {
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 09:49 PM
you might be able to use a flow for this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 06:08 AM
So, I used the following script, and it WORKED!!!
but I cannot get it working when I had 2 extensions Mp3 and Wav, it only works with Wav
Any suggestions?
(function executeRule(current, previous /*null when async*/) {
// Check if the record has attachments with the extension MP3
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_sys_id', current.sys_id);
attachmentGR.addQuery('file_name', 'LIKE', '%.wav');
attachmentGR.query();
if (attachmentGR.next()) {
// If attachments with MP3 extension found, change contact_method to EMAIL
current.contact_method = 'Phone';
}
})(current, previous);