Creating a new record on attachment insert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 05:13 AM
Hi all, I have a requirement like this- I have got two tables - Table A and Table B My requirement - 1. If an attachment is attached to a record A001 in table A, then create a new record B001 in table B 2. Also, if the attachment is updated with a new one on record A001, then delete the old record B001 and create a new record B002 in table B How the above can be achieved?? Thanks advance!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 05:20 AM
Hi Kunal,
This is the role of an AFTER business rule. You can create a business rule on sys_attachment (not table a) to watch for updates, inserts, deletions, etc that include the source table A and take the appropriate action on table B...
Reference:
Business Rules - ServiceNow Wiki
Business Rules Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 05:26 AM
Hi Kunal,
You will have to write a business rule on attachment table i.e. sys_attachment
Have an after insert business rule with following condition so that it runs only for your table
current.table_name == 'tableA'
Script
var gr = new GlideRecord('tableB');
gr.initialize();
gr.field1 = 'hello'; // have your fields here which you want to populate
gr.insert();
I don't think you can determine if attachment is updated or not. When you attach new attachment it creates new record in sys_attachment table
So the second functionality is somewhat not achievable
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2021 01:48 AM
Hi,
Can you please help me with the code for a dynamic attachment in a notification?
Requirement is - User is selecting Request Type as Export Group Members and file should be sent to Requested For with the list of Group members in that particular group.
File varies from group to group. Please help me with the code for this.
Thanks