- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 03:04 AM
Hi,
when the user submits the catalog request by attaching the spreadsheet/file and that file need to be added/present in catalog task...how can we do that.
Thanks in advance
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 03:21 AM
@suuriya You can add an onBefore Insert Business rule on Catalog Task table as follows.
Here is the script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.request.hasAttachments()){
var attachment = new GlideSysAttachment();
attachment.copy('sc_request',current.request.getValue('sys_id'),'sc_task',current.getValue('sys_id'));
}
})(current, previous);
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 03:14 AM
Hi @suuriya
You can use "GlideSysAttachment()" class & use copy() function available OOTB
You can do this in Catalog task (in script part ) in Workflow or flow designer :
var task_sysid = task.setNewGuidValue(); //set new GUID to task
var atta = new GlideSysAttachment();
var result = atta.copy('sc_req_item', current.getUniqueValue(), 'sc_task',task_sysid );
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 12:31 AM
HI @Vishal Birajdar ,
I tried this in WF Catalog task script part but it throws an error and task is not created so i commented it and checked task created....seems some issue in script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 03:21 AM
@suuriya You can add an onBefore Insert Business rule on Catalog Task table as follows.
Here is the script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.request.hasAttachments()){
var attachment = new GlideSysAttachment();
attachment.copy('sc_request',current.request.getValue('sys_id'),'sc_task',current.getValue('sys_id'));
}
})(current, previous);
Hope this helps.