Oscar Lopez
Mega Guru
Mega Guru

Remember that you can create a global function that can be called whenever you need in the back-end.

In this particular case the members of a group must be pulled in order to filter a User reference field in the form by a Group reference field in the same form. This is a typical example of Assignment Group and Assigned To inter-dependency. When you choose a group in the Assignment Group field, the Assigned To field should only display user members of the group selected.

find_real_file.png

With a simple global business rule you can filter the Assigned To field easily:

function getGroupMembers(fieldName) {
    var groupValue = current.getValue(fieldName);

    if (gs.nil(groupValue)) {
        return "active=true^EQ";
    }

    var member = new GlideRecord("sys_user_grmember");
    member.addQuery("group", groupValue);
    member.query();

    var list = [];
    while (member.next()) {
        list.push(member.getValue("user"));
    }
    return "sys_idIN" + list.toString();
}

 

Here an example:

find_real_file.png

Easy, clean and practical in the data dictionary of the Assigned To field:

find_real_file.png

 

 

 

 

 

Comments
Allen Andreas
Administrator
Administrator

Hi,

Thanks for the post.

Just to clarify that this can be done, easily, without any of this by just setting the dependency of the assigned_to field...to that of the assignment_group, which is already an OOB setting and set for the assigned_to field on the Incident table, for example:

find_real_file.png

This filters the users that show within the assigned_to to those of the assignment_group.

Slava Savitsky
Giga Sage

In the base system, there is a global business rule Report Helpers that contains a function with that name. If you want to create your own function, consider giving it a different name to avoid conflicts. By the way, this is one of the reasons why using global business rules is generally not a good practice.

Version history
Last update:
‎03-27-2020 05:44 PM
Updated by: