How to remove images from the email inbound actions for specific inbound action record ??

sai97
Tera Contributor

Hi All,

We have 3 inbound actions for the legal space application. (custom Application)

We'd like those inbound actions to remove images from the email. We had tried to implement this be referring some community post i.e. creating system properties but its unsuccessful. What would be the easiest way for you to handle this? 

- Thanks !

1 ACCEPTED SOLUTION

Chandu Telu
Tera Guru

Hi Sai,

You can modify the same inbound action to delete the inserted attachment which start with name image. Using email.uid you can find the sys_id of email record and then you can query that in sys attachment and delete the attachment.

Sample code 

email_sysId = "sys id of inbound email"

var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name','sys_email');
gr.addQuery('table_sys_id',email_sysId);
gr.addQuery('file_name','STARTSWITH','Image');
gr.query();

if(gr.next()){
gr.deleteRecord();
}

 

https://community.servicenow.com/community?id=community_question&sys_id=c7c96673dbe20550bb4a474d1396192a

Thanks
Chandu Telu
Please Mark Correct/helpful, if applicable,

View solution in original post

4 REPLIES 4

Chandu Telu
Tera Guru

Hi Sai,

You can modify the same inbound action to delete the inserted attachment which start with name image. Using email.uid you can find the sys_id of email record and then you can query that in sys attachment and delete the attachment.

Sample code 

email_sysId = "sys id of inbound email"

var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name','sys_email');
gr.addQuery('table_sys_id',email_sysId);
gr.addQuery('file_name','STARTSWITH','Image');
gr.query();

if(gr.next()){
gr.deleteRecord();
}

 

https://community.servicenow.com/community?id=community_question&sys_id=c7c96673dbe20550bb4a474d1396192a

Thanks
Chandu Telu
Please Mark Correct/helpful, if applicable,

Hi Chandu,

Thank you for reply, Could you please let us know the above mentioned where we should write, because the above code looks like executing in background script. should we require to write the above code in inbound actions on script part ??.

-Thanks !

Hi Sai,

You can write this last lines of inbound email action - Let me know you face any issues as this code not tested

 

Thanks
Chandu Telu
Please Mark Correct/helpful, if applicable,

Hi,

 

Now we can use the sys_email variable to access the GlideRecord referencing the current email:

 

https://docs.servicenow.com/en-US/bundle/tokyo-servicenow-platform/page/administer/notification/refe...

 

So to retrieve the email sys_id can be done this way:

 

gr.addQuery('table_sys_id', sys_email.sys_id);

 

Regards