The CreatorCon Call for Content is officially open! Get started here.

I need to reflect the values of 'u_members' field in the 'sys_user_grmember' table. Please help..

Mycena Jane Cam
Tera Contributor

I am trying to reflect all the modified values of member field and reflect it in the 

sys_user_grmember table. This is a catalog item for example as a manager I wanted to add a member on a specific assignment group. After adding the eid of the member and submitted the request I wanted to reflect the changes in the sys_user_group table but specific in the RLI of the assignment group which is the Group members. Existing configurations are in the script actions which I added the glide record for the group members table. Please help..
 
Script Actions:
MycenaJaneCam_0-1709552348315.png
var members = current.variables.u_members.toString();
    var arrMembers = members.split(',');
    for (var i = 0; i < arrMembers.length; i++) {
        var userID = arrMembers[i].trim();

        var groupMember = GlideRecord('sys_user_grmember');
        groupMember.addQuery('user', userID);
        groupMember.addQuery('group', current.sys_id);
        groupMember.query();

        if (!groupMember.next()) {
            groupMember.initialize();
            groupMember.user = userID;
            groupMember.group = current.sys_id;
            groupMember.insert();
        } else {
            groupMember.user = userID;
            groupMember.update();
        }
    }
 
This is an example of the request item.
MycenaJaneCam_1-1709552505434.png

 

Where I need to reflect the changes whether to insert or update. Thanks.

 

MycenaJaneCam_0-1709555983558.png

 

5 REPLIES 5

Kieran Anson
Kilo Patron

Hi,

What do you mean by the 'RLI' of the group?

Related List of the Group Table which is the table Group Member.

Anand Kumar P
Giga Patron

Hi @Mycena Jane Cam ,

Try below script by adding current variables assignment group.

var members = current.variables.u_members.toString();
var arrMembers = members.split(',');
for (var i = 0; i < arrMembers.length; i++) {
var userID = arrMembers[i].trim();
var groupMember = new GlideRecord('sys_user_grmember');
groupMember.addQuery('user', userID);
groupMember.addQuery('group', current.variables.u_assignment_group);
groupMember.query();
if (!groupMember.next()) {
groupMember.initialize();
groupMember.user = userID;
groupMember.group = current.variables.u_assignment_group;
groupMember.insert();
} else {
groupMember.user = userID;
groupMember.update();
}
}

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Still not reflecting the values.