Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

run business rule after attaching file

irvin2
Giga Contributor

I need to run a business rule after attaching a file to a record .. I can do this by clicking on the save button (or update) however I would prefer to update the record as soon as the file is attached without needing to press the save or update button

8 REPLIES 8

Nate23
Mega Guru

so is your requirement to run a br when an attachment has been attached or to save the record when an attachment is made?



if you need to run a BR just trigger off of the sys_attachment table when table name = 'whatever table you want'



if you want to save the record I think this depends if you are doing this in service portal or not...


antin_s
ServiceNow Employee
ServiceNow Employee

Along with what Nathan has mentioned, you might want to check the value of 'table_sys_id' in the sys_attachement to the current record sys_id in the Business Rule to make sure the Business Rule runs only when a record in inserted for the current record to which you are adding the attachment.



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



Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin


Chuck Tomasi
Tera Patron

Hi Irvin,



What is the underlying requirement here? What do you want to do with this BR when you attach a file to that record? It sounds like you've got a technical solution picked out without us understanding the requirement which could provide additional options.



http://xyproblem.info/


Hi Chuck


When a attachment is added to a record in Servicenow, i have written a BR to execute a REST message to send the attachment to 3rd party tool.


Unless there is any save/update on current record, my BR wont trigger.


What can be best approach to achieve that?