UI Builder Dropdown--Members of a Group or Users with a Role

Velma
Tera Guru

I would like to populate the Items property of a dropdown with the members of a group or users with a role. How might I go about this? (And sort?)

1 ACCEPTED SOLUTION

Velma
Tera Guru

Okay, my steps (this is for group members only; I have not figured out roles):

1--Add a Lookup Records data resource against sys_user_grmember with a condition of Group is [your group name], return fields User, order by User. (I did the filter on the table and copied it.)

2--Add a Transform data resource and ACL using in general Brad Tilton's transform data resource video: https://www.youtube.com/watch?v=4IXL7Ki2oxI&list=PL3rNcyAiDYK0dbKPzncc05eFUPYQCs8Me&index=6&t=9s

3--Make the transform data resource do the right things with help from other posts in the forum. I ended up with
Properties:

[
{
"name": "data",
"label": "data",
"description": "Transform Users for Assignee Dropdown",
"readOnly": false,
"fieldType": "json",
"valueType": "object",
"mandatory": true
}
]

Script:
function transform(input){
var dropdownJSONArray = [];
var records = input.data;

for (var counter in records){
var record = records[counter];
var assignee = {};
assignee.id = record.user.value;
assignee.label = record.user.displayValue;
dropdownJSONArray.push(assignee);
}

return dropdownJSONArray;
}

4--Bind the lookup records output to the transform input, e.g., @data.look_up_im_team_members.results

5--Bind the transform output to the dropdown Items property, e.g.,  @data.transform_users_for_assignee_dropdown_1.output

I don't know if that is the easiest way but it works. 

View solution in original post

1 REPLY 1

Velma
Tera Guru

Okay, my steps (this is for group members only; I have not figured out roles):

1--Add a Lookup Records data resource against sys_user_grmember with a condition of Group is [your group name], return fields User, order by User. (I did the filter on the table and copied it.)

2--Add a Transform data resource and ACL using in general Brad Tilton's transform data resource video: https://www.youtube.com/watch?v=4IXL7Ki2oxI&list=PL3rNcyAiDYK0dbKPzncc05eFUPYQCs8Me&index=6&t=9s

3--Make the transform data resource do the right things with help from other posts in the forum. I ended up with
Properties:

[
{
"name": "data",
"label": "data",
"description": "Transform Users for Assignee Dropdown",
"readOnly": false,
"fieldType": "json",
"valueType": "object",
"mandatory": true
}
]

Script:
function transform(input){
var dropdownJSONArray = [];
var records = input.data;

for (var counter in records){
var record = records[counter];
var assignee = {};
assignee.id = record.user.value;
assignee.label = record.user.displayValue;
dropdownJSONArray.push(assignee);
}

return dropdownJSONArray;
}

4--Bind the lookup records output to the transform input, e.g., @data.look_up_im_team_members.results

5--Bind the transform output to the dropdown Items property, e.g.,  @data.transform_users_for_assignee_dropdown_1.output

I don't know if that is the easiest way but it works.