<?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 Update multiple records with background script in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759433#M416359</link>
    <description>&lt;P&gt;I need to update couple of the records with the help of the background script. The field I need to update is a free text field, which = to value NAAM. I need to update it so it says NAM.&lt;/P&gt;
&lt;P&gt;Here's the script I'm using but it's not working - anyone knows why?&lt;/P&gt;
&lt;P&gt;var rg = new GlideRecord('incident');&lt;BR /&gt;rg.addQuery("u_alias1", "=", "NAAM");&lt;BR /&gt;rg.query();&lt;BR /&gt;while(rg.next){&lt;BR /&gt;rg.u_alias1="NAM";&lt;BR /&gt;rg.update();&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Tue, 14 Sep 2021 08:42:15 GMT</pubDate>
    <dc:creator>Dawid2</dc:creator>
    <dc:date>2021-09-14T08:42:15Z</dc:date>
    <item>
      <title>Update multiple records with background script</title>
      <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759433#M416359</link>
      <description>&lt;P&gt;I need to update couple of the records with the help of the background script. The field I need to update is a free text field, which = to value NAAM. I need to update it so it says NAM.&lt;/P&gt;
&lt;P&gt;Here's the script I'm using but it's not working - anyone knows why?&lt;/P&gt;
&lt;P&gt;var rg = new GlideRecord('incident');&lt;BR /&gt;rg.addQuery("u_alias1", "=", "NAAM");&lt;BR /&gt;rg.query();&lt;BR /&gt;while(rg.next){&lt;BR /&gt;rg.u_alias1="NAM";&lt;BR /&gt;rg.update();&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 08:42:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759433#M416359</guid>
      <dc:creator>Dawid2</dc:creator>
      <dc:date>2021-09-14T08:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Update multiple records with background script</title>
      <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759434#M416360</link>
      <description>&lt;P&gt;try with&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var rg = new GlideRecord('incident');
rg.addQuery("u_alias1", "=", "NAAM");
rg.query();
while(rg.next()){
rg.setValue('u_alias1','NAM');
rg.update();
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Sep 2021 08:44:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759434#M416360</guid>
      <dc:creator>Martin Ivanov</dc:creator>
      <dc:date>2021-09-14T08:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Update multiple records with background script</title>
      <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759435#M416361</link>
      <description>&lt;P&gt;The problem was that you were missing the brackets after the .next() method.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please makr Correct and Helpful. Thanks&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 08:45:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759435#M416361</guid>
      <dc:creator>Martin Ivanov</dc:creator>
      <dc:date>2021-09-14T08:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Update multiple records with background script</title>
      <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759436#M416362</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please do you setworkflow(false) and autosysfield(false) as well so that it wil not trigger or update user that you doing something at backend&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;var rg = new GlideRecord('incident');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;rg.addQuery("u_alias1", "=", "NAAM");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;rg.query();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;while(rg.next()){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;rg.u_alias1="NAM";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;rg.setWorkflow(false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;rg.autoSysFields(false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;rg.update();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;Please mark it helpful and correct if your query get resolved&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;Himanshu Gupta&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 08:52:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759436#M416362</guid>
      <dc:creator>Himanshu Gupta1</dc:creator>
      <dc:date>2021-09-14T08:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Update multiple records with background script</title>
      <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759437#M416363</link>
      <description>&lt;P&gt;Hi Dawid&lt;/P&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var rg = new GlideRecord('incident');
rg.addQuery("u_alias1", "=", "NAAM");
rg.query();
rg.setValue('u_alias1',"NAM");
rg.updateMultiple(); &lt;/LI-CODE&gt;
&lt;P&gt;&lt;A href="https://community.servicenow.com/community?id=community_article&amp;amp;sys_id=53e36473dbd244502be0a851ca96190d" target="_blank"&gt;https://community.servicenow.com/community?id=community_article&amp;amp;sys_id=53e36473dbd244502be0a851ca96190d&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can also achieve this with no-coding using update-selected/update all option.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.servicenow.com/bundle/rome-platform-user-interface/page/use/using-lists/task/t_EditMultiRecUsingEditingForm.html" target="_blank"&gt;https://docs.servicenow.com/bundle/rome-platform-user-interface/page/use/using-lists/task/t_EditMultiRecUsingEditingForm.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 14:41:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/1759437#M416363</guid>
      <dc:creator>Voona Rohila</dc:creator>
      <dc:date>2022-11-24T14:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Update multiple records with background script</title>
      <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/2394662#M934946</link>
      <description>&lt;P&gt;Hi Rohila&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Never directly assign a value to a variable and call multipleUpdate()!&lt;/P&gt;&lt;P&gt;That will cause all records of the table to have the value changed whatever the query!!&lt;/P&gt;&lt;P&gt;Always use .setValue() together with updateMultiple()!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please fix your comment or remove it before someone, for some reason, decides to use your way of updating the records and actually destroy data in the table!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Nuno Agapito&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 14:24:01 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/2394662#M934946</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2022-11-24T14:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Update multiple records with background script</title>
      <link>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/2394694#M934957</link>
      <description>&lt;P&gt;Thank You Nuno, I modified the code.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 14:44:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/update-multiple-records-with-background-script/m-p/2394694#M934957</guid>
      <dc:creator>Voona Rohila</dc:creator>
      <dc:date>2022-11-24T14:44:19Z</dc:date>
    </item>
  </channel>
</rss>

