- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2025 11:26 PM
Hi @Utpal Dutta ,
when you add an attachment to the record producer it will add it to sys_attachment table with table name as the record producer tableName and sysid = sysid of the task which is not yet generated ( this sysid will be allocated to to the record once you submit the record)
it's not recommend to use the setAbortaction method inside record producer script and might not work as intended as per docs
so better create a before insert BR on the table
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
07-21-2025 11:28 PM
Hello @Utpal Dutta ,
In addition to @Chaitanya ILCR point, you can copy the attachment from one table to another table using Glidesysattachment method.
// For example
var attachment = new GlideSysAttachment();
var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc';
var incGR = new GlideRecord('incident');
incGR.get(incidentSysID);
var copiedAttachments = attachment.copy('incident', incidentSysID, 'problem', incGR.getValue('problem_id'));
gs.info('Copied attachments: ' + copiedAttachments);
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2025 11:40 PM
Hi @Utpal Dutta,
step1: Open your record producer
specify record producer if you are working on (eg.issue management- Record Producer)
step2. add the script to the Record producer
Here is the script to copy attachments in Record Producer
var newRec = new GlideRecord 'incident);//or any other table
newRec.short-description = 'created from Record producer';
newRec.description ='This record was created through a producer';
newRec.insert();
//Now copy attachments from the record producer to the new record
var sa - new GlideSysAttachment();
sa.copy('sc_item_produced_record',current.sys_id,newRec.getTableName(), newRec.sys_id);
//adjust source table name in teh .copy() line if needed
use 'sc_item_produced_record' if the attachement is saved there
step3: save the Record Producer
Testing:
1.Service catalog-> record producer and fill the form and attach a file -> submit
2. go to the target table (eg.incident in this example )
3. open a new record and check if the attachment is present.
Please mark as Correct Answer/Helpful, if applicable.
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 05:31 AM
Thanks, this worked for me but I had to first identify to which table my attachment was attaching to when I add it on the catalog item form. It seems like it is same as record producer's table.
Since I have my record producer on Incident table I ran your script something like below.
var sa - new GlideSysAttachment();
sa.copy('incident',current.sys_id,'request', 'SYSID of Request');
Thanks again for helping me out here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 06:23 AM
You didn't share your business requirement though.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader