<?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: Bulk data upload with import set from excel in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520023#M6576</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1017732"&gt;@ektamestri&lt;/a&gt;&lt;BR /&gt;In your onAfter Script, the for loop ends after&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; if (!locName) continue;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;that is why only one location is getting created. the for loop should end after&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;else {
        log.error("Location not Found: " + locName);
    }&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P class=""&gt;Please mark it helpful, if it helps.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Regards,&lt;/P&gt;&lt;P class=""&gt;Kali&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Apr 2026 08:17:48 GMT</pubDate>
    <dc:creator>MAHAMKALI</dc:creator>
    <dc:date>2026-04-06T08:17:48Z</dc:date>
    <item>
      <title>Bulk data upload with import set from excel</title>
      <link>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520016#M6575</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to update bulk data which is present in spreadsheet.&amp;nbsp; Here, I am updating existing incidents (major incidents), in which I also need to upload data related to affected locations, impacted services etc.&amp;nbsp; I have created a transform map for affected locations separately because affected locations (task_location) which is present on incident table as related list.&amp;nbsp; &amp;nbsp;I need to update &lt;STRONG&gt;multiple locations per task&lt;/STRONG&gt; in task_location for which I have crated onAfter transform script and I have only mapped incident number to task.&amp;nbsp; &amp;nbsp;How should I go about this scenario.&amp;nbsp; I am pasting onAfter script as well.&amp;nbsp; Can you please give any suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//GET INCIDENT SYS_ID&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var incGR = new GlideRecord('incident');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; incGR.addQuery('number', source.u_incident_number);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //incGR.setLimit(1);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; incGR.query();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!incGR.next()) {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log.error('Incident not found: ' + source.u_incident_number);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //split multiple locations&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var locations = source.u_affected_locations.toString().split(',');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (var i = 0; i &amp;lt; locations.length; i++) {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var locName = locations[i].trim();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!locName) continue;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //find location record&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var locGR = new GlideRecord('cmn_location');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; locGR.addQuery('name', locName);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; locGR.query();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (locGR.next()) {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var checkGR = new GlideRecord('task_location');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; checkGR.addQuery('task', incGR.sys_id);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; checkGR.addQuery('location', locGR.sys_id);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; checkGR.query();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!checkGR.next())&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var taskLocGR = new GlideRecord('task_location');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; taskLocGR.initialize();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; taskLocGR.task = incGR.sys_id;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; taskLocGR.location = locGR.sys_id;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; taskLocGR.insert();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; } else {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; log.error("Location not Found: " + locName);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;})(source, map, log, target);&lt;/DIV&gt;</description>
      <pubDate>Mon, 06 Apr 2026 07:44:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520016#M6575</guid>
      <dc:creator>ektamestri</dc:creator>
      <dc:date>2026-04-06T07:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Bulk data upload with import set from excel</title>
      <link>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520023#M6576</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1017732"&gt;@ektamestri&lt;/a&gt;&lt;BR /&gt;In your onAfter Script, the for loop ends after&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; if (!locName) continue;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;that is why only one location is getting created. the for loop should end after&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;else {
        log.error("Location not Found: " + locName);
    }&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P class=""&gt;Please mark it helpful, if it helps.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Regards,&lt;/P&gt;&lt;P class=""&gt;Kali&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2026 08:17:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520023#M6576</guid>
      <dc:creator>MAHAMKALI</dc:creator>
      <dc:date>2026-04-06T08:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Bulk data upload with import set from excel</title>
      <link>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520025#M6577</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1017732"&gt;@ektamestri&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is your updated script, your script had issues with the loop&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {


    //GET INCIDENT SYS_ID

    var incGR = new GlideRecord('incident');
    incGR.addQuery('number', source.u_incident_number);
    //incGR.setLimit(1);
    incGR.query();

    if (!incGR.next()) {
        log.error('Incident not found: ' + source.u_incident_number);
        return;
    }
    //split multiple locations

    var locations = source.u_affected_locations.toString().split(',');
    for (var i = 0; i &amp;lt; locations.length; i++) {

        var locName = locations[i].trim();
        if (!locName) continue;
        //find location record

        var locGR = new GlideRecord('cmn_location');
        locGR.addQuery('name', locName);
        locGR.query();
        if (locGR.next()) {
            var checkGR = new GlideRecord('task_location');
            checkGR.addQuery('task', incGR.sys_id);
            checkGR.addQuery('location', locGR.sys_id);
            checkGR.query();
            if (!checkGR.hasNext()) {
                var taskLocGR = new GlideRecord('task_location');
                taskLocGR.initialize();
                taskLocGR.task = incGR.sys_id;
                taskLocGR.location = locGR.sys_id;
                taskLocGR.insert();
            }
        } else {
            log.error("Location not Found: " + locName);
        }
    }

})(source, map, log, target);&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":light_bulb:"&gt;💡&lt;/span&gt; If my response helped, please mark it as correct &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; and close the thread &lt;span class="lia-unicode-emoji" title=":locked:"&gt;🔒&lt;/span&gt;— this helps future readers find the solution faster! &lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2026 08:41:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520025#M6577</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2026-04-06T08:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Bulk data upload with import set from excel</title>
      <link>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520042#M6578</link>
      <description>&lt;P&gt;hey&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1017732"&gt;@ektamestri&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;try this :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(function runTransformScript(source, map, log, target) {

    // Get Incident
    var incGR = new GlideRecord('incident');
    incGR.addQuery('number', source.u_incident_number);
    incGR.query();

    if (!incGR.next()) {
        log.error('Incident not found: ' + source.u_incident_number);
        return;
    }

    // Split locations
    var locations = source.u_affected_locations.toString().split(',');

    for (var i = 0; i &amp;lt; locations.length; i++) {

        var locName = locations[i].trim();
        if (!locName) continue;

        // Find location
        var locGR = new GlideRecord('cmn_location');
        locGR.addQuery('name', locName);
        locGR.query();

        if (locGR.next()) {

            // Check if already exists
            var checkGR = new GlideRecord('task_location');
            checkGR.addQuery('task', incGR.sys_id);
            checkGR.addQuery('location', locGR.sys_id);
            checkGR.query();

            if (!checkGR.next()) {

                var taskLocGR = new GlideRecord('task_location');
                taskLocGR.initialize();
                taskLocGR.task = incGR.sys_id;
                taskLocGR.location = locGR.sys_id;
                taskLocGR.insert();

            }

        } else {
            log.error("Location not found: " + locName);
        }
    }

})(source, map, log, target);&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;*************************************************************************************************************************************&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this response helps, please mark it as Accept as Solution and Helpful.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Doing so helps others in the community and encourages me to keep contributing.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Vaishali Singh&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2026 09:12:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520042#M6578</guid>
      <dc:creator>vaishali231</dc:creator>
      <dc:date>2026-04-06T09:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Bulk data upload with import set from excel</title>
      <link>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520073#M6580</link>
      <description>&lt;P&gt;Thank you everyone.&amp;nbsp; Also, onAfter did not work, I used run script for this scenario and it worked fine&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2026 10:25:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/bulk-data-upload-with-import-set-from-excel/m-p/3520073#M6580</guid>
      <dc:creator>ektamestri</dc:creator>
      <dc:date>2026-04-06T10:25:29Z</dc:date>
    </item>
  </channel>
</rss>

