<?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: Setting and Reusing Variables During Import Transform in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169581#M826507</link>
    <description>&lt;P&gt;Thank you for providing the first clear explanation (that I could find) on declaring variables usable throughout an import transform.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Apr 2021 09:49:57 GMT</pubDate>
    <dc:creator>Goran</dc:creator>
    <dc:date>2021-04-15T09:49:57Z</dc:date>
    <item>
      <title>Setting and Reusing Variables During Import Transform</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169577#M826503</link>
      <description>&lt;P&gt;During an import, how do I set a variable once and reference it during other transform map stages?&lt;/P&gt;
&lt;P&gt;We have an import that 5 different scripts:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 Transform Scripts: onStart (1), onBefore(2), &amp;amp; onAfter (5)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 Field Maps script (3)&amp;nbsp;to identify the sys_id by multiple criteria&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 "base" script on the Table Transform Map screen (4)&lt;/P&gt;
&lt;P&gt;Each script has a different purpose but the scripts share certain variables of the same values calculated with the same criteria. How can I calculate the variables once and reference them in the other scripts?&lt;/P&gt;
&lt;P&gt;I believe that the scripts process in the following order: onStart (1), onBefore(2),&amp;nbsp;Field Maps script (3), "base" script (4), &amp;amp; onAfter (5). The onStart script only initializes (gs.include…) our custom version of the LDAPUtils Script Includes. The other scripts call additional scripts from our custom version of the LDAPUtils Script Includes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 13:19:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169577#M826503</guid>
      <dc:creator>MGanon</dc:creator>
      <dc:date>2020-03-20T13:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and Reusing Variables During Import Transform</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169578#M826504</link>
      <description>&lt;P&gt;Declare variable in an onStart script and it's available to other scripts within the transform process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sachin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 15:34:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169578#M826504</guid>
      <dc:creator>sachin_namjoshi</dc:creator>
      <dc:date>2020-03-20T15:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and Reusing Variables During Import Transform</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169579#M826505</link>
      <description>&lt;P&gt;For clarity: "&lt;STRONG&gt;this.&lt;/STRONG&gt;" and not "var " in front of the variable.&lt;/P&gt;
&lt;P&gt;Declaring a "var " variable in an onStart script does not&amp;nbsp;set that variable for the rest of the transformation but a "this." variable does. Example: importBudgetItemTransform transform map&lt;/P&gt;
&lt;P&gt;For example, add this to the onStart map:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var DeclaredVar = "Declared Variable";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.thisvar = "this.variable for whole map";:&lt;/P&gt;
&lt;P&gt;The rest of the scripts (onBefore, field mapping, run script, onAfter, etc.) will read and can use the "this.thisvar" variable but abend with the "DeclaredVar" variable.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 17:21:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169579#M826505</guid>
      <dc:creator>MGanon</dc:creator>
      <dc:date>2020-03-28T17:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and Reusing Variables During Import Transform</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169580#M826506</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;So if you declare a variable using this keyword then it is accessible in all other further scripts&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 14:54:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169580#M826506</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-04-12T14:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and Reusing Variables During Import Transform</title>
      <link>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169581#M826507</link>
      <description>&lt;P&gt;Thank you for providing the first clear explanation (that I could find) on declaring variables usable throughout an import transform.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 09:49:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/setting-and-reusing-variables-during-import-transform/m-p/2169581#M826507</guid>
      <dc:creator>Goran</dc:creator>
      <dc:date>2021-04-15T09:49:57Z</dc:date>
    </item>
  </channel>
</rss>

