<?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 Background Script not updating all returned Glide Records in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897638#M554564</link>
    <description>&lt;P&gt;I have a list of groups that I wanted to update they types of, and since the field type of lists can't be edited from List View, I put together a quick background script to update them all for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14628070838038052" data-renderedposition="50_8_1192_144" jivemacro_uid="_14628070838038052"&gt;&lt;P&gt;var gr = new GlideRecord('sys_user_group');&lt;/P&gt;&lt;P&gt;gr.query();&lt;/P&gt;&lt;P&gt;gs.log("!!!!!!!!!!!ROW COUNT: " + gr.getRowCount() + "!!!!!!!!!!");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while (gr.next()) {&lt;/P&gt;&lt;P&gt;gr.type = '74af88c6c611227d0066386e74dc853d,e906721d4f1b9200c9f4fd511310c790,5fe5721d4f1b9200c9f4fd511310c764,faf5721d4f1b9200c9f4fd511310c78f';&lt;/P&gt;&lt;P&gt;//gr.update();&lt;/P&gt;&lt;P&gt;gs.log(gr.name.toString());&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code worked well. It returned a full list of groups by name. However, when I un-commented like 7 to actually have the groups updated with the list of types (line 6), it stops prematurely. It doesn't appear to "break", and the records it is able to get through get updated as desired. I put the list count at the top to confirm that it is still getting the whole list of groups, and it Confirms that the GlideRecord IS querying all 76 groups. (The one strange thing I noticed is that when it isn't working, the second to last return is blank).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: medium;"&gt;[0:00:00.182] Script completed in scope global: script&lt;/SPAN&gt;&lt;/P&gt;&lt;HR style="color: #000000; font-family: 'Times New Roman'; font-size: medium;" /&gt;&lt;PRE style="color: #000000;"&gt;*** Script: !!!!!!!!!!!ROW COUNT: 76!!!!!!!!!!&lt;BR /&gt;*** Script: L3 Technology Support Center&lt;BR /&gt;*** Script: L3 Infrastructure Engineering&lt;BR /&gt;*** Script: L3 Identity Management&lt;BR /&gt;*** Script: L3 Service Delivery and Program Management&lt;BR /&gt;*** Script: L3 ESI Process Management&lt;BR /&gt;*** Script: L3 Multimedia&lt;BR /&gt;*** Script: L3 ES Mobility&lt;BR /&gt;*** Script: ServiceNow Admin&lt;BR /&gt;*** Script: &lt;BR /&gt;*** Script: zIT Managers&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea why it keeps stopping? or how I can possibly put some error catching in my code?&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2016 15:25:16 GMT</pubDate>
    <dc:creator>Community Alums</dc:creator>
    <dc:date>2016-05-09T15:25:16Z</dc:date>
    <item>
      <title>Background Script not updating all returned Glide Records</title>
      <link>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897638#M554564</link>
      <description>&lt;P&gt;I have a list of groups that I wanted to update they types of, and since the field type of lists can't be edited from List View, I put together a quick background script to update them all for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14628070838038052" data-renderedposition="50_8_1192_144" jivemacro_uid="_14628070838038052"&gt;&lt;P&gt;var gr = new GlideRecord('sys_user_group');&lt;/P&gt;&lt;P&gt;gr.query();&lt;/P&gt;&lt;P&gt;gs.log("!!!!!!!!!!!ROW COUNT: " + gr.getRowCount() + "!!!!!!!!!!");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while (gr.next()) {&lt;/P&gt;&lt;P&gt;gr.type = '74af88c6c611227d0066386e74dc853d,e906721d4f1b9200c9f4fd511310c790,5fe5721d4f1b9200c9f4fd511310c764,faf5721d4f1b9200c9f4fd511310c78f';&lt;/P&gt;&lt;P&gt;//gr.update();&lt;/P&gt;&lt;P&gt;gs.log(gr.name.toString());&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code worked well. It returned a full list of groups by name. However, when I un-commented like 7 to actually have the groups updated with the list of types (line 6), it stops prematurely. It doesn't appear to "break", and the records it is able to get through get updated as desired. I put the list count at the top to confirm that it is still getting the whole list of groups, and it Confirms that the GlideRecord IS querying all 76 groups. (The one strange thing I noticed is that when it isn't working, the second to last return is blank).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Times New Roman'; font-size: medium;"&gt;[0:00:00.182] Script completed in scope global: script&lt;/SPAN&gt;&lt;/P&gt;&lt;HR style="color: #000000; font-family: 'Times New Roman'; font-size: medium;" /&gt;&lt;PRE style="color: #000000;"&gt;*** Script: !!!!!!!!!!!ROW COUNT: 76!!!!!!!!!!&lt;BR /&gt;*** Script: L3 Technology Support Center&lt;BR /&gt;*** Script: L3 Infrastructure Engineering&lt;BR /&gt;*** Script: L3 Identity Management&lt;BR /&gt;*** Script: L3 Service Delivery and Program Management&lt;BR /&gt;*** Script: L3 ESI Process Management&lt;BR /&gt;*** Script: L3 Multimedia&lt;BR /&gt;*** Script: L3 ES Mobility&lt;BR /&gt;*** Script: ServiceNow Admin&lt;BR /&gt;*** Script: &lt;BR /&gt;*** Script: zIT Managers&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea why it keeps stopping? or how I can possibly put some error catching in my code?&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 15:25:16 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897638#M554564</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2016-05-09T15:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Background Script not updating all returned Glide Records</title>
      <link>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897639#M554565</link>
      <description>&lt;P&gt;I've confirmed mine does something similar with 24 groups and stops after two (with a noted blank entry also.) Something is staring me in the face and I'm not seeing it (yet).&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 May 2016 15:31:46 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897639#M554565</guid>
      <dc:creator>Chuck Tomasi</dc:creator>
      <dc:date>2016-05-09T15:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Background Script not updating all returned Glide Records</title>
      <link>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897640#M554566</link>
      <description>&lt;P&gt;I found it has something to do with the Type field (glide_list). I can set other fields like active=true and it's fine. Still working...&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 May 2016 15:38:01 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897640#M554566</guid>
      <dc:creator>Chuck Tomasi</dc:creator>
      <dc:date>2016-05-09T15:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Background Script not updating all returned Glide Records</title>
      <link>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897641#M554567</link>
      <description>&lt;P&gt;This seems unfortunate because that is the whole reason I did it &lt;SPAN __jive_emoticon_name="sad" __jive_macro_name="emoticon" class="jive_emote jive_macro" data-renderedposition="8_417_16_16" src="https://www.servicenow.com/8.0.1.35b65d4/images/emoticons/sad.png"&gt;&lt;/SPAN&gt;...the other fields I can update from List View&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 May 2016 15:42:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897641#M554567</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2016-05-09T15:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Background Script not updating all returned Glide Records</title>
      <link>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897642#M554568</link>
      <description>&lt;P&gt;This smells like a bug. I'd call for support on this. The script I wrote has some debugging in it to help determine what's going on. If you watch what happens to the sys_id, it fails on a null value (which is where the blank entry second to the end is coming around), then updates the record and stops - like it jumped to the end of the list of records. If you run it again, it gets one more record further each time and does the same thing. If you ran your script 74 times, it would eventually push through, but that's silly.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1462809317257442 jive_text_macro" data-renderedposition="91.6335220336914_7.997159004211426_1192_170" jivemacro_uid="_1462809317257442"&gt;&lt;P&gt;var gr = new GlideRecord('sys_user_group'); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;gr.query(); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;gs.log("!!!!!!!!!!!ROW COUNT: " + gr.getRowCount() + "!!!!!!!!!!"); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;while (gr.next()) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; gs.log('10: sys_id=' + gr.getValue('sys_id'));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; gr.type = 74af88c6c611227d0066386e74dc853d,e906721d4f1b9200c9f4fd511310c790,5fe5721d4f1b9200c9f4fd511310c764,faf5721d4f1b9200c9f4fd511310c78f';&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; gs.log('20: sys_id=' + gr.getValue('sys_id'));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; gs.log('update id=' + gr.update());&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; gs.log(gr.name.toString() + ' sys_id=' + gr.getValue('sys_id')); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 May 2016 15:55:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/background-script-not-updating-all-returned-glide-records/m-p/1897642#M554568</guid>
      <dc:creator>Chuck Tomasi</dc:creator>
      <dc:date>2016-05-09T15:55:25Z</dc:date>
    </item>
  </channel>
</rss>

