Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

attachment.uploaded event triggering and subsequent scripting

verdakosnett
Tera Expert

I have form on which i track who uploaded what attachment as in the screen capture below:

find_real_file.png

This works fine as long as the form is submitted but obviously it is no good if a user drags a file to the form. So, I registered an event as follows:

find_real_file.png

I then wrote a business rule:

find_real_file.png

and nothing happened....Where did I go wrong?

1 ACCEPTED SOLUTION

Yes as chuck mentioned, it should be an after BR. What is the field type of attachment_links and is it a custom field ?


View solution in original post

23 REPLIES 23

Abhinay Erra
Giga Sage

You need a business rule on sys_attachment table. Because adding an attachment will not update the record, so writing business rule on the task table will not help.


So, how do I access the record to which an attachment was attached. Is it impossible?


Wait, i think   I have it. I use the current.sys id and get the current.table_sys_id, which should give me the record id.


Yes, in the sys_attachment table, you will have both the table and sys_id of the record in that table.


Abhinay Erra
Giga Sage

This is how you can access the record



var gr= new GlideRecord(current.table_name);


if(gr.get(current.table_sys_id)){


//do your manipulation here


}