Populate list with specific group members.

Ishenferi
Tera Contributor

Hello all!

 

My client has a group we'll call EOY, and the list of EOY membership will change from year to year. However, all records created need to have these EOY members listed, and there is currently a glide_list field on the record. Is there a simple way to include this group's membership on that list? I am able to set the current members (3) as a default value, but I want something that can scale later.

 

Thanks for any suggestions!

3 REPLIES 3

James Chun
Kilo Patron

Hi @Ishenferi,

 

Are you saying that the glide_list field should reflect the current group member no matter when the record was created?

If so, I think it would be ideal to use the group record as the reference here.

 

Cheers

 

Not quite. 

 

If this year there are Users X,Y, and Z, they would appear on all records created.

If next year there are Users X, Y, Z, and T, they would appear on all records created at that time.

When you said 'set the current members (3) as a default value' did you mean you hard-coded the sys_ids of the members?

 

You can write up a script something like below and use it within the Default value.

Note that I am assuming the glide_list is referencing the [sys_user] table.

javascript: getMembers();

function getMembers() {
    var memArr = [];
    var member = new GlideRecord('sys_user_grmember');
    member.addQuery('group.name', 'App Engine Admins'); //replace with your group name or use sys_id
    member.query();
    while (member.next()) {
        memArr.push(member.getValue('user'));
    }
    return memArr.join(',');
}

JamesChun_0-1717009622378.png