Business rule to be executed only when if there is any attachment added to the incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 07:45 PM
Hi,
We have a requirement to send attachment to third party application. Please help me on the business rule.
Business rule to be executed only when if there is any attachment added to the incident.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 09:38 PM
Hello Hari
Try This
1. Create a Business Rule on sys_attachment table which will run for every insert for your table name and for any content_type you want.
2. In the Business rule, take the 'current.table_sys_id' from the sys_attachment table and query your table to update any field you want or use gs.addInfoMessage()..etc
var attachment = new GlideRecord('sys_attachment'); attachment.addQuery('table_name', 'incident'); attachment.addQuery('table_sys_id', current.sys_id); attachment.query(); while (attachment.next()) { //send attachment to third party application }
Please mark helpful or Correct If it Helped you
Regards
Hemant Kumar Ch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 02:11 AM
Hi @Hari S1 You need to write business rule after for incident table and copy this script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr=new GlideRecord('sys_attachment');
gr.addQuery('table_name','incident');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gs.addInfoMessage("attachment is present");
}
else{
gs.addInfoMessage("no attachment present");
}
})(current, previous);
The above script will throw the message when there is an any attachment in the current inc record and for me it's working fine.
If my solution helps you please mark my Solution Accepted and Helpful.
Thanks and regards
Uday Kumar Valapudasu