- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2025 11:14 PM
Hi community members,
I'm working on a record producer where I need to get value of "Attachment" in my record producer script.
I need this because I'm aboring action of record producer and inserting that record somewhere else. When I'm inserting that record I need the attachment which is added by the user in Record producer to be attached in that record.
Any ideas or suggestions are helpful.
Thanks
Solved! Go to Solution.
- 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
Chiranjeevi
ServiceNow Developer | | ITSM | | ServiceNow Discovery | | Event Management | | Service Mapping | | CMDB
Please mark as Correct Answer/Helpful, if applicable.
- 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
Chiranjeevi
ServiceNow Developer | | ITSM | | ServiceNow Discovery | | Event Management | | Service Mapping | | CMDB
Please mark as Correct Answer/Helpful, if applicable.
- 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 || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 01:51 AM - edited 07-23-2025 01:53 AM
Hey Ankur,
Sorry couldn't reply you earlier. It is related to a requirement for which I already posted a community question . You can find it here.
Basically we don't need record producer to insert a record in table. We are creating a request with RITMs using cart with this record producer.
I wanted to capture attachment which is added to record producer and populate it in Request which Record producer has created.
I hope it helps in understanding the requirement.