Scheduled Script Execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 12:51 AM
Is there a better way to write it or a simpler way or a way to maintain it later?
var gr= new GlideRecord('sys_user_grmember');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 01:02 AM
@system You can choose to create a system property with following structure.
"{'GroupA': 'ec6fb87747f1311047d9afcf016d438b','GroupB: '<sys_id of group B>','GroupC': '<sys_id of group C>'}";
in your code you can access the property as follows.
var groupObj = JSON.parse(gs.getProperty('<property name>'));
var gr= new GlideRecord('sys_user_grmember');
// Agroup
var tifi = gr.addQuery('group', groupObj.GroupA);
// Bgroup
tifi .addOrCondition('group', groupObj.GroupB);
//Cgroup
tifi .addOrCondition('group', groupObj.GroupC);
gr.query();
if (gr.getRowCount() != 0) {
gr.setWorkflow(false);
gr.deleteMultiple();
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 01:07 AM
Thank you very much for your answer
If you add it to a Property, if you add a new group later, should you add the Property first and then add the script? Will maintenance become complicated?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 01:20 AM
Yes, you nee to. That is an ideal way as you need to maintain things at one place instead of muliple places and help avoid hardcoding.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 05:37 PM
Thank you very much for your answer.
I don't want to use sysid to add directly, but I haven't thought of a better way. It's nerve-wracking, because the group searched here needs to be added with qualified users.