- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 12:48 AM
Hi, how to bulk update using fix script i just want to try update the company field using dummy data from Microsoft company to Tesla company.
Thak you in Advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 12:55 AM
Hi @Community Alums
You can use updateMultiple() method on GlideRecord class. For example,
var gr = new GlideRecord("YOUR_TABLE_NAME");
gr.addEncodedQuery("Your_Query"); //if you want to update all records in table you can remove this line
gr.query();
gr.company = "Sys ID of your company record from core_company field"; //I assume your field is reference to core_company table.
gr.updateMultiple();
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 01:02 AM
Hi @Community Alums ,
You can try something like this
// Define a GlideRecord query to find records with the current company name "Microsoft"
var gr = new GlideRecord('your_table_name'); // Replace 'your_table_name' with the actual table name you want to update
gr.addQuery('company', 'Microsoft');
gr.query();
// Loop through the records and update the company name to "Tesla"
while (gr.next()) {
gr.company = 'Tesla';
gr.update();
}
gs.info('Bulk update completed. Records with company name "Microsoft" changed to
"Tesla".');
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 12:55 AM
Hi @Community Alums
You can use updateMultiple() method on GlideRecord class. For example,
var gr = new GlideRecord("YOUR_TABLE_NAME");
gr.addEncodedQuery("Your_Query"); //if you want to update all records in table you can remove this line
gr.query();
gr.company = "Sys ID of your company record from core_company field"; //I assume your field is reference to core_company table.
gr.updateMultiple();
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 01:05 AM
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 01:02 AM
Hi @Community Alums ,
You can try something like this
// Define a GlideRecord query to find records with the current company name "Microsoft"
var gr = new GlideRecord('your_table_name'); // Replace 'your_table_name' with the actual table name you want to update
gr.addQuery('company', 'Microsoft');
gr.query();
// Loop through the records and update the company name to "Tesla"
while (gr.next()) {
gr.company = 'Tesla';
gr.update();
}
gs.info('Bulk update completed. Records with company name "Microsoft" changed to
"Tesla".');
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 01:06 AM
Thank you so much!