Attachment from record producer attachment variable not getting attached to the backend record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Experts,
I have a Record Producer on a custom table with an attachment variable which is not mapped to any backend field on the target table. I need that whenever an attachment comes from that attachment variable from record producer, it should be attached to the backend record. It is not happening because on the 'sys_attachment' table, the attachment record is created with table name having prefix 'ZZ_YY'. I am trying to remove that prefix using the script below but it is not updating it.
Its an after insert business rule applied to the target table. I have given cross scope permission to write on 'sys_attachment' table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Swapnil Srivas1 ,
1. try copying the attachment
or
2. create a script include in the global application and shift the code that you have written there and make it accessible from all application scopes and call that script include
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
35m ago
Hi @Chaitanya ILCR ,
Copying won't be helpful as it will create the attachment entries two times on the activity stream.
I tried the second approach but that also didn't worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi there @Swapnil Srivas1
An after insert Business Rule on the target table often runs before ServiceNow finishes re-associating those attachments, so updating sys_attachment.table_name there won’t work reliably. Instead of manually updating sys_attachment, the recommended approach is to let ServiceNow handle the move by mapping the attachment variable (or using producer.attachments.copy(targetTable, targetSysId) in the Record Producer script). If you must script it, run the logic asynchronously (or via a scheduled/queued job) after the record producer finishes, and update both table_name and table_sys_id. Directly changing sys_attachment in a synchronous BR is not supported and often gets overwritten by the platform.
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
34m ago
Hi @Its_Azar ,
I tried an async insert business rule and tried to update both table name and table sys id, but that also didn't worked.
