<?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: Copying Data from one Catalog Task to another Catalog Task in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850815#M507741</link>
    <description>&lt;P&gt;thank you very much. Worked like a charm!&lt;/P&gt;</description>
    <pubDate>Thu, 01 Sep 2022 14:34:56 GMT</pubDate>
    <dc:creator>Jake Golden</dc:creator>
    <dc:date>2022-09-01T14:34:56Z</dc:date>
    <item>
      <title>Copying Data from one Catalog Task to another Catalog Task</title>
      <link>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850811#M507737</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently trying to pull information from task 1 to default into task 2. The fields I am targeting are associated with the Configuration Item table and my task are Catalog Tasks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, task 1 requires the user to select an asset in the Configuration Item table. Once the item has been selected, there are two additional field, 'owned by' and 'Computer Name'. The additional fields will be filled out and once the task is completed, those fields write back to the CI table. Upon completion of task 1, task 2 is auto generated from the workflow. Now on task 2 I would like to auto populate the CI value, owned by, and computer name that had been entered on task 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 19:13:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850811#M507737</guid>
      <dc:creator>Jake Golden</dc:creator>
      <dc:date>2022-08-31T19:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Data from one Catalog Task to another Catalog Task</title>
      <link>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850812#M507738</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="5d1fb2d8db51115021b59b3c8a96198d"&gt;@Jake Golden&lt;/SN-MENTION&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the sample script that you can use.&lt;/P&gt;
&lt;P&gt;Inside &lt;CODE&gt;if(grTask.next()){...}&lt;/CODE&gt; you can add fields to copy from ctask 1 to ctask 2.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;task represents ctask2 and grTask represents ctask1.&lt;/P&gt;
&lt;P&gt;e.g. if you want to copy assigned_to so you would do something like this&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;task.assigned_to = grTask.assigned_to&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;// Set values for the task in this script.  Use the variable 'task' when setting additional values.
// Note: This script is run after the task values are set using the Fields, Template or Values you have specified.
//
// For example:
//     task.short_description = current.short_description;

var grTask = new GlideRecord("sc_task");
grTask.addQuery("sys_id", current.getValue('sys_id'));
//grTask.addQuery('short_description', "SHORT DESCRIPTION OF FIRST TASK");
grTask.query();

if(grTask.next()){
	task.cmdb_ci = grTask.cmdb_ci; 
	task.short_description = grTask.short_description;
	//add more fields here
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please try and let me know if you face any issues.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Please mark this helpful/correct, if applicable.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Muhammad&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 04:11:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850812#M507738</guid>
      <dc:creator>MrMuhammad</dc:creator>
      <dc:date>2022-09-01T04:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Data from one Catalog Task to another Catalog Task</title>
      <link>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850813#M507739</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the reply Muhammad. I tried copying the above script and only used the script below in the if() statement&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;task.short_description = grTask.short_description;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I was unsuccessful in pulling any data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another hole I dug into was using the scratchpad. Is it possible to delay when this script runs? As we see:&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;// Note: This script is run after the task values are set using the Fields, Template or Values you have specified.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I can delay the task 1 script to run after closer of task, I could accomplish this through the scratchpad. But currently the scratchpad will only capture information at opening of ticket as that is when the script runs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am more than happy to continue on the path you suggested just now, but figured I would ask this question as well for another possible solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;
&lt;P&gt;Jake&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 04:49:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850813#M507739</guid>
      <dc:creator>Jake Golden</dc:creator>
      <dc:date>2022-09-01T04:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Data from one Catalog Task to another Catalog Task</title>
      <link>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850814#M507740</link>
      <description>&lt;P&gt;Hello Jake,&lt;/P&gt;
&lt;P&gt;So when you are creating your &lt;STRONG&gt;Task 1&lt;/STRONG&gt; set the &lt;EM&gt;&lt;STRONG&gt;Order &lt;/STRONG&gt;&lt;/EM&gt;field of that task as &lt;EM&gt;&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/EM&gt; and you can use the below script in your &lt;EM&gt;&lt;STRONG&gt;Create Catalog Task&lt;/STRONG&gt;&lt;/EM&gt; activtiy for Task 2:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var scTask = new GlideRecord("sc_task");
scTask.addEncodedQuery("request_item=" + current.getUniqueValue() + "^state=3^order=100");
scTask.query();
if(scTask.next()){
	task.cmdb_ci = scTask.getValue("cmdb_ci") 
	task.short_description = scTask.getValue("short_description");
	task.u_owned_by = scTask.getValue("u_owned_by"); //CHECK YOUR FIELD NAME AND REPLACE IF REQUIRED
	task.u_computer_name = scTask.getValue("u_computer_name"); //CHECK YOUR FIELD NAME AND REPLACE IF REQUIRED
	task.order = 200;
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Please mark my respsone as helpful/correct, if it answer your question.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 06:54:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850814#M507740</guid>
      <dc:creator>Mahendra RC</dc:creator>
      <dc:date>2022-09-01T06:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Data from one Catalog Task to another Catalog Task</title>
      <link>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850815#M507741</link>
      <description>&lt;P&gt;thank you very much. Worked like a charm!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 14:34:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/copying-data-from-one-catalog-task-to-another-catalog-task/m-p/1850815#M507741</guid>
      <dc:creator>Jake Golden</dc:creator>
      <dc:date>2022-09-01T14:34:56Z</dc:date>
    </item>
  </channel>
</rss>

