- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-29-2024 12:06 AM
Hi Guys!
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 ''u_year_end_date'' field based on "employment_end_date" field. The thing is in list view the ''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).
Can you give me a had with this?
Also, this is the client script that I'm using:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-29-2024 01:18 AM
Hi Robert,
If I understand correctly you have created a new field u_year_end_date and wish to populate the value in this field for all existing records submitted before the field was created.
If so, you need fix script or background script to update it for existing records as below.
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();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-29-2024 12:16 AM
Hi @robertpetrovics ,
If you want to update all the record of any table you can run the background script you can refer the sample script
var gr = new GlideRecord('incident');
gr.query('active', true);
gr.query();
while(gr.next()){
gr.setValue('field_name', 'Updated Value');
gr.updateMultiple();
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-29-2024 12:31 AM
your query is not clear ! can you break down your question.
āļø Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-29-2024 12:43 AM
Basically I only need to update the records so that the on load client script can run and do the modifications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-29-2024 01:11 AM
You would need to create a client client script and a ajax call to update all the relevent record.
āļø Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....