<?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 How to copy attachments from Case to Case task in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3054406#M1147852</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;How to copy attachments from Case to Case Task, it is in custom app and both table are custom created.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whenever Case Task is being created from Case copy attachments from Case to Case Task. Case Task is a &lt;STRONG&gt;related list&lt;/STRONG&gt; on Case form and its like Parent(Case) to Child(Case Task) relationship.&lt;/P&gt;&lt;P&gt;I have tried below BR Code and I need help in to add a query to get a matching record from Tasks related List&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried below &lt;STRONG&gt;before Insert Update BR&lt;/STRONG&gt; on &lt;STRONG&gt;Case Task&lt;/STRONG&gt;, but its not working.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    var grCase = new GlideRecord('case');
    grCase.addQuery('parent', current.sys_id); // here need help on how to add query to get a matching record from Related list
    grCase.query();
    if (grCase.next()) {
        new GlideSysAttachment.copy('case_task', current.sys_id, 'case', grCase.sys_id);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Sep 2024 15:15:59 GMT</pubDate>
    <dc:creator>The Matrix</dc:creator>
    <dc:date>2024-09-24T15:15:59Z</dc:date>
    <item>
      <title>How to copy attachments from Case to Case task</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3054406#M1147852</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;How to copy attachments from Case to Case Task, it is in custom app and both table are custom created.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whenever Case Task is being created from Case copy attachments from Case to Case Task. Case Task is a &lt;STRONG&gt;related list&lt;/STRONG&gt; on Case form and its like Parent(Case) to Child(Case Task) relationship.&lt;/P&gt;&lt;P&gt;I have tried below BR Code and I need help in to add a query to get a matching record from Tasks related List&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried below &lt;STRONG&gt;before Insert Update BR&lt;/STRONG&gt; on &lt;STRONG&gt;Case Task&lt;/STRONG&gt;, but its not working.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    var grCase = new GlideRecord('case');
    grCase.addQuery('parent', current.sys_id); // here need help on how to add query to get a matching record from Related list
    grCase.query();
    if (grCase.next()) {
        new GlideSysAttachment.copy('case_task', current.sys_id, 'case', grCase.sys_id);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 15:15:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3054406#M1147852</guid>
      <dc:creator>The Matrix</dc:creator>
      <dc:date>2024-09-24T15:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy attachments from Case to Case task</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3054421#M1147859</link>
      <description>&lt;P&gt;You'll probably want this to trigger only before insert so it's not copied every time the case task is updated.&amp;nbsp; You'll need to add some logs to see if the GR is returning any records, but the GlideSysAttachment.copy method arguments are 'from' and 'to' in that order, and it doesn't sound like the case_task is the parent of the case, which is what you are querying for, so if you have a field named 'parent' on the case_task table that gets populated with the case, then it would be more like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var grCase = new GlideRecord('case');
grCase.addQuery('sys_id',  current.parent); 
grCase.query();
if (grCase.next()) {
    new GlideSysAttachment.copy('case', grCase.sys_id, 'case_task', current.sys_id);
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are 'case' and 'case_task' the complete table names?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 11:28:07 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3054421#M1147859</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-09-26T11:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy attachments from Case to Case task</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3054434#M1147862</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Here is a modified script which might work:&lt;/P&gt;&lt;P&gt;Try this BR as Before Insert/Update on &lt;STRONG&gt;Case Task.&amp;nbsp;&lt;/STRONG&gt;If this Case is of HR Case then the table is sn_hr_core_case and its child is sn_hr_core_task and if its from Customer Case it has different name. Use the right one for your scenario.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if (current.parent) {&lt;BR /&gt;var grCase = new GlideRecord('case'); //case can be sn_hr_core_case&lt;BR /&gt;if (grCase.get(current.parent)) {&lt;BR /&gt;new GlideSysAttachment().copy('case', grCase.sys_id, 'case_task', current.sys_id); //here as well replace 'case' and 'case_task'&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 15:37:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3054434#M1147862</guid>
      <dc:creator>Akash4</dc:creator>
      <dc:date>2024-09-24T15:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy attachments from Case to Case task</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3056460#M1148417</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/174062"&gt;@Brad Bowman &lt;/a&gt;&amp;nbsp;Need one suggestion,&lt;/P&gt;&lt;P&gt;How can I add check in BR, so that when attachments is added only that time BR will trigger and it will not copy same file again n again?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 05:10:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3056460#M1148417</guid>
      <dc:creator>The Matrix</dc:creator>
      <dc:date>2024-09-26T05:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy attachments from Case to Case task</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3056902#M1148518</link>
      <description>&lt;P&gt;By changing the When to Run to only before Insert, since the rule is on the case_task table it will only run when a task is created.&amp;nbsp; If there's the possibility that the case didn't have an attachment when the task was created, and you want to copy it to each task when it is added to the case, then you would need another Business Rule after insert on the attachment table.&amp;nbsp; That script would look like this:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var grCaseTask = new GlideRecord('case_task');
grCaseTask.addQuery('parent',  current.table_sys_id); 
grCaseTask.query();
while (grCaseTask.next()) {
    new GlideSysAttachment.copy('case', current.table_sys_id, 'case_task', grCaseTask.sys_id);
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Sep 2024 11:27:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-copy-attachments-from-case-to-case-task/m-p/3056902#M1148518</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-09-26T11:27:38Z</dc:date>
    </item>
  </channel>
</rss>

