Trouble deleting record from sys_user_grmember table - info message is only unexpected message.

Lon Landry4
Mega Sage

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

8 REPLIES 8

Prateek kumar
Mega Sage

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

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...

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

Lon Landry4
Mega Sage

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.