<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Copy attachment from Request form to SC task form in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2587579#M1006846</link>
    <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/519769"&gt;@suresh1995&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why to copy and increase the attachment table size?&lt;/P&gt;
&lt;P&gt;why not just show the files in related list? check below link&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-blog/tnt-quot-related-attachments-quot-related-list/ba-p/2266788" target="_blank" rel="noopener"&gt;TNT: "Related Attachments" Related List&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you still want to copy then use this script&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;(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);&lt;/LI-CODE&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2023 08:53:37 GMT</pubDate>
    <dc:creator>Ankur Bawiskar</dc:creator>
    <dc:date>2023-06-14T08:53:37Z</dc:date>
    <item>
      <title>Copy attachment from Request form to SC task form</title>
      <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2585434#M1005904</link>
      <description>&lt;P&gt;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 &amp;amp; i have wrote the after business rule&amp;nbsp; in request from&amp;nbsp; but it's not work . kindly guide me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Business rule:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;executeRule(current,&amp;nbsp;previous&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;/*null&amp;nbsp;when&amp;nbsp;async*/&lt;/SPAN&gt;&lt;SPAN&gt;)&amp;nbsp;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;//GlideSysAttachment.copy('sc_task',current.sys_id&amp;nbsp;,&amp;nbsp;'sc_request',&amp;nbsp;current.request_item);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//&amp;nbsp;Add&amp;nbsp;your&amp;nbsp;code&amp;nbsp;here&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;id&amp;nbsp;=&amp;nbsp;current.table_sys_id;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;gr&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'sc_task'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;gr.addQuery(&lt;/SPAN&gt;&lt;SPAN&gt;'sys_id'&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;id);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;gr.query();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(gr.next()){&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;ritm&amp;nbsp;=&amp;nbsp;gr.request_item;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;att&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'sys_attachment'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.initialize();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.file_name&amp;nbsp;=&amp;nbsp;current.file_name;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.content_type&amp;nbsp;=&amp;nbsp;current.content_type;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.compressed&amp;nbsp;=&amp;nbsp;current.compressed;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.table_name&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'sc_request'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.size_bytes&amp;nbsp;=&amp;nbsp;current.size_bytes;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.size_compressed&amp;nbsp;=&amp;nbsp;current.size_compressed;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;att.table_sys_id&amp;nbsp;=&amp;nbsp;ritm;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;attRec&amp;nbsp;=&amp;nbsp;att.insert();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;attDoc&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'sys_attachment_doc'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDoc.addQuery(&lt;/SPAN&gt;&lt;SPAN&gt;'sys_attachment'&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;current.sys_id);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDoc.query();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;while&lt;/SPAN&gt;&lt;SPAN&gt;(attDoc.next()){&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;attDocCopy&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'sys_attachment_doc'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDocCopy.initialize();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDocCopy.sys_attachment&amp;nbsp;=&amp;nbsp;attRec;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDocCopy.position&amp;nbsp;=&amp;nbsp;attDoc.position;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDocCopy.length&amp;nbsp;=&amp;nbsp;attDoc.length;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDocCopy.data&amp;nbsp;=&amp;nbsp;attDoc.data;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attDocCopy.insert();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;})(current,&amp;nbsp;previous);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Jun 2023 12:11:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2585434#M1005904</guid>
      <dc:creator>suresh1995</dc:creator>
      <dc:date>2023-06-12T12:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Copy attachment from Request form to SC task form</title>
      <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2585537#M1005935</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 13:30:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2585537#M1005935</guid>
      <dc:creator>KristenA1641094</dc:creator>
      <dc:date>2023-06-12T13:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Copy attachment from Request form to SC task form</title>
      <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2586418#M1006262</link>
      <description>&lt;P&gt;Hi Thanks for your reply but my task is same attachment will show in request item form &amp;amp; SCtask form using business rule .I want to know how to match the attachment kindly assist me.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 09:11:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2586418#M1006262</guid>
      <dc:creator>suresh1995</dc:creator>
      <dc:date>2023-06-13T09:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Copy attachment from Request form to SC task form</title>
      <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2586761#M1006388</link>
      <description>&lt;P&gt;If they must have it copied, then you should use the GlideSysAttachment API:&amp;nbsp;&lt;A href="https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/GlideSysAttachmentGlobalAPI#GSA-GlideSysAttachment?navFilter=attach" target="_blank"&gt;https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/GlideSysAttachmentGlobalAPI#GSA-GlideSysAttachment?navFilter=attach&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 13:34:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2586761#M1006388</guid>
      <dc:creator>KristenA1641094</dc:creator>
      <dc:date>2023-06-13T13:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Copy attachment from Request form to SC task form</title>
      <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2587563#M1006836</link>
      <description>&lt;P&gt;Thank you for your reply , but still not working&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;After business rule &amp;amp; condition: table name -is- sc_task&lt;/P&gt;&lt;P&gt;script:&lt;/P&gt;&lt;P&gt;(function executeRule(current, previous /*null when async*/) {&lt;/P&gt;&lt;P&gt;var taskRec = new GlideRecord(current.table_name.toString());&lt;BR /&gt;taskRec.addQuery("sys_id", current.table_sys_id.toString());&lt;BR /&gt;taskRec.query();&lt;/P&gt;&lt;P&gt;if(taskRec.next()){&lt;BR /&gt;GlideSysAttachment.copy(current.table_name.toString(), current.table_sys_id.toString(), "sc_task", taskRec.request.toString());&lt;BR /&gt;}&lt;BR /&gt;})(current, previous);&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 08:40:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2587563#M1006836</guid>
      <dc:creator>suresh1995</dc:creator>
      <dc:date>2023-06-14T08:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Copy attachment from Request form to SC task form</title>
      <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2587579#M1006846</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/519769"&gt;@suresh1995&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why to copy and increase the attachment table size?&lt;/P&gt;
&lt;P&gt;why not just show the files in related list? check below link&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-blog/tnt-quot-related-attachments-quot-related-list/ba-p/2266788" target="_blank" rel="noopener"&gt;TNT: "Related Attachments" Related List&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you still want to copy then use this script&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;(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);&lt;/LI-CODE&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 08:53:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2587579#M1006846</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2023-06-14T08:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Copy attachment from Request form to SC task form</title>
      <link>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2587721#M1006904</link>
      <description>&lt;P&gt;Thanks for your help&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 10:31:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copy-attachment-from-request-form-to-sc-task-form/m-p/2587721#M1006904</guid>
      <dc:creator>suresh1995</dc:creator>
      <dc:date>2023-06-14T10:31:58Z</dc:date>
    </item>
  </channel>
</rss>

