- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 01:26 AM - edited ā02-27-2024 01:50 AM
Hi
we have a requirement to deactivate HR services in bulk(320) , so we need to create fix script for this
The conditions were : the table should be in employee relations case and topic category is one of "audit","tracking" and so on..(many topic categories)
Like if the service is from employee relations table and topic category is one of the given, the respective HR services should be inactive
Please suggest me if this is possible and if its possible please help me with fix script
@Dr Atul G- LNG @AndersBGS @Mark Manders
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 02:26 AM
Hi @sri vijaya ,
if those filters can be applied manually on the table then it is doable without scripting. What u can do is after applying filter u can Right click on any column n select Data Management option where u will get 2 more options:
- Delete all with preview
- Update all with preview
Select update all with preview. It will open up a data management record for u with applied filter. under field u can select the respective field which u want to update for eg active n set it to false.
once done & saved click on execute now. This will update all records from the list view for which u applied the filter in 1 go without any script.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 02:44 AM
Hi @sri vijaya
NO need to do with script. Filter the results on list view and update in on go by Update all.
Expert @Danish Bhairag2 already provided a quick way.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 02:16 AM
Hey @sri vijaya,
It's just 320 records, surely you can just update them in bulk on the list view?
That should take a couple minutes or so.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 02:26 AM
Hi @sri vijaya ,
if those filters can be applied manually on the table then it is doable without scripting. What u can do is after applying filter u can Right click on any column n select Data Management option where u will get 2 more options:
- Delete all with preview
- Update all with preview
Select update all with preview. It will open up a data management record for u with applied filter. under field u can select the respective field which u want to update for eg active n set it to false.
once done & saved click on execute now. This will update all records from the list view for which u applied the filter in 1 go without any script.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 02:33 AM
Try:
var topicCategories = ["audit", "tracking", /* add more topic categories as needed */];
// Query Employee Relations Case table to identify records meeting the conditions
var caseGr = new GlideRecord('table_name'); // Replace 'table_name' with the actual table name of Employee Relations Case
caseGr.addQuery('topic_category', 'IN', topicCategories);
caseGr.query();
while (caseGr.next()) {
// Update HR service associated with the current case to set it as inactive
var hrServiceGr = new GlideRecord('hr_service_table');
hrServiceGr.addQuery('case', caseGr.sys_id); // Assuming 'case' is the reference field linking HR service to Employee Relations Case
hrServiceGr.query();
while (hrServiceGr.next()) {
hrServiceGr.active = false;
hrServiceGr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2024 02:44 AM
Hi @sri vijaya
NO need to do with script. Filter the results on list view and update in on go by Update all.
Expert @Danish Bhairag2 already provided a quick way.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************