Trouble deleting record from sys_user_grmember table - info message is only unexpected message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:16 AM - edited 06-15-2023 11:39 AM
Howdy Community,
I am having touble deleting record from sys_user_grmember table - info message is only unexpected message.
I do not get any error messages.
Info message = type: m2m, name[sys_user_grmember] view[null]
All gs.logs copmplete as expected with sys_id of group member record I am trying to delete.
The current result is a sys_user_grmember record with the user removed but the record is not deleted and still shows in user's groups.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var groupRecordX = new GlideRecord('sys_user_grmember');
groupRecordX.record = current.sys_id; //get the sys_id of current group member record
gs.log(groupRecordX.record);
groupRecordX.query();
while (groupRecordX.next()){
groupRecordX.deleteRecord(); //Remove the user from TEST group in user's record
gs.log(groupRecordX.record);
return;}
})(current, previous);
Any ideas?
Thanks for your time,
Lon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 01:19 PM
Ok then current.sys_id will give you your current custom table record and not sys_user_grmember record. So dotwalk and get the sys_id something like current.group_variable.sys_id;
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 02:27 PM
I have tried many combinations, but nothing gets me to the data I need.
Maybe there a limitation posed by custom table making this impossible in ServiceNow...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 02:29 PM
Without knowing the table structure of your's we cannot get the sys_id of the group member record.
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 01:29 PM
Thanks for your help, I look forward to trying this first thing in the morning, I will mark correct if I can find a solution.