- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2023 05:11 AM
Hi all, i have the task that if i attached one file in request form in catalog item , that same attachment will automatically reflected in SC task from & i have wrote the after business rule in request from but it's not work . kindly guide me
Business rule:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 01:53 AM
why to copy and increase the attachment table size?
why not just show the files in related list? check below link
TNT: "Related Attachments" Related List
If you still want to copy then use this script
(function executeRule(current, previous /*null when async*/) {
var taskRec = new GlideRecord('sc_task');
taskRec.addQuery("request_item.request", current.table_sys_id.toString());
taskRec.query();
while(taskRec.next()){
GlideSysAttachment.copy(current.table_name.toString(), current.table_sys_id.toString(), "sc_task", taskRec.sys_id.toString());
}
})(current, previous);
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
06-12-2023 06:30 AM
Rather than copying the files to the tasks, which can exponentially increase the size of you attachment table, I would suggest creating a defined related list on sc_task that has a filter to show the attachments from the task and its parent requested item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 02:11 AM
Hi Thanks for your reply but my task is same attachment will show in request item form & SCtask form using business rule .I want to know how to match the attachment kindly assist me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 06:34 AM
If they must have it copied, then you should use the GlideSysAttachment API: https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/GlideSysAttachmentGlobal...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 01:40 AM
Thank you for your reply , but still not working
Task : when i upload any attachment in sc_request form ,it should also been seen in sc_task form . i tried below script but its not working ,kindly guide me
After business rule & condition: table name -is- sc_task
script:
(function executeRule(current, previous /*null when async*/) {
var taskRec = new GlideRecord(current.table_name.toString());
taskRec.addQuery("sys_id", current.table_sys_id.toString());
taskRec.query();
if(taskRec.next()){
GlideSysAttachment.copy(current.table_name.toString(), current.table_sys_id.toString(), "sc_task", taskRec.request.toString());
}
})(current, previous);