<?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: Update all the records on a table in HRSD forum</title>
    <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912534#M36277</link>
    <description>&lt;P&gt;You would need to create a client client script and a ajax call to update all the relevent record.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Apr 2024 08:11:09 GMT</pubDate>
    <dc:creator>Sohail Khilji</dc:creator>
    <dc:date>2024-04-29T08:11:09Z</dc:date>
    <item>
      <title>Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912422#M36270</link>
      <description>&lt;P&gt;Hi Guys!&lt;/P&gt;&lt;P&gt;I need to update all the records on the ''sn_hr_core_profile'' in order to run the on load/on change client script that I created. The script autopopulates the ''&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;u_year_end_date'' field based on "&lt;SPAN&gt;employment_end_date" field. The thing is in list view the&amp;nbsp;''u_year_end_date' field is empty unless I'm going into a record and save it( so that the on load/on change client script can run).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Can you give me a had with this?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Also, this is the client script that I'm using:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; onChange(control, oldValue, newValue, isLoading, isTemplate) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;//if (isLoading || newValue === '') {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;//return;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;//}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; employmentEndDate = g_form.getValue(&lt;/SPAN&gt;&lt;SPAN&gt;'employment_end_date'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (employmentEndDate) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; year = parseInt(employmentEndDate.substring(&lt;/SPAN&gt;&lt;SPAN&gt;6&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;10&lt;/SPAN&gt;&lt;SPAN&gt;));&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setValue(&lt;/SPAN&gt;&lt;SPAN&gt;'u_year_end_date'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'31-12-'&lt;/SPAN&gt;&lt;SPAN&gt;+ year );&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;</description>
      <pubDate>Mon, 29 Apr 2024 07:06:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912422#M36270</guid>
      <dc:creator>robertpetrovics</dc:creator>
      <dc:date>2024-04-29T07:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912436#M36271</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/620572"&gt;@robertpetrovics&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;If you want to update all the record of any table you can run the background script you can refer the sample script&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var gr = new GlideRecord('incident');
gr.query('active', true);
gr.query();
while(gr.next()){
	gr.setValue('field_name', 'Updated Value');
	gr.updateMultiple();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please mark my answer correct and helpful if this works for you&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sarthak&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 07:16:54 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912436#M36271</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-04-29T07:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912464#M36273</link>
      <description>&lt;P&gt;your query is not clear ! can you break down your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 07:31:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912464#M36273</guid>
      <dc:creator>Sohail Khilji</dc:creator>
      <dc:date>2024-04-29T07:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912489#M36275</link>
      <description>&lt;P&gt;Basically I only need to update the records so that the on load client script can run and do the modifications.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 07:43:54 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912489#M36275</guid>
      <dc:creator>robertpetrovics</dc:creator>
      <dc:date>2024-04-29T07:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912534#M36277</link>
      <description>&lt;P&gt;You would need to create a client client script and a ajax call to update all the relevent record.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 08:11:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912534#M36277</guid>
      <dc:creator>Sohail Khilji</dc:creator>
      <dc:date>2024-04-29T08:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912536#M36278</link>
      <description>&lt;P&gt;how can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 08:13:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912536#M36278</guid>
      <dc:creator>robertpetrovics</dc:creator>
      <dc:date>2024-04-29T08:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912550#M36279</link>
      <description>&lt;P&gt;Hi Robert,&lt;/P&gt;
&lt;P&gt;If I understand correctly you have created a new field&amp;nbsp;&lt;SPAN&gt;u_year_end_date and wish to populate the value in this field for all existing records submitted before the field was created.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If so, you need fix script or background script to update it for existing records as below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var gr = new GlideRecord('sn_hr_core_profile');
gr.setLimit(10);//do it for 10 records.. once it works fine comment this line
gr.query();
while(gr.next()){
var valueis=parseInt((gr.employment_end_date).substring(6,10));
	gr.setValue('u_year_end_date', '31-12-'+valueis);
	gr.updateMultiple();
}

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 08:18:41 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912550#M36279</guid>
      <dc:creator>Jaspal Singh</dc:creator>
      <dc:date>2024-04-29T08:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Update all the records on a table</title>
      <link>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912666#M36282</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/620572"&gt;@robertpetrovics&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me give you one solution on this,&lt;/P&gt;&lt;P&gt;If your client script is working as per your expectation, then you can simply run that same block of script in the BackGround script OR fix script. You just need to Glide the HR profile table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var gr = new GlideRecord('sn_hr_core_profile');
gr.addActiveQuery();
gr.setLimit(10);
gr.query();
while(gr.next()){
var yearEnd= parseInt((gr.employment_end_date).substring(6,10));
	gr.setValue('u_year_end_date', '31-12-' + yearEnd);
	gr.update();
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Apr 2024 09:32:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/update-all-the-records-on-a-table/m-p/2912666#M36282</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-04-29T09:32:59Z</dc:date>
    </item>
  </channel>
</rss>

