Foreach to save value

In DB i have table  with columns firstnam,emailid and lastname data, I want to show in Dropdown firstanam,lastname and after selecting dropdown value want to query same table to get emailid 

Step 1: get firstname and lastname to concate and store in array for dropdown purpose

local!fn:{index(rule!PTS_QueryUsers(local!selectedDept),"firstName",{})},
local!ls:{index(rule!PTS_QueryUsers(local!selectedDept),"lastName",{})},
local!user:if(isnull(local!selectedDept),{},union(apply(fn!concatenate, merge(local!fn, local!ls)),apply(fn!concatenate, merge(local!fn, local!ls)))),

Step 2: Show firstname and lastname to concate and store in array for dropdown purpose

a!dropdownField(
label: "Assigned Name",
labelPosition: "ADJACENT",
placeHolder: "Select User",
choiceLabels:
a!forEach(
items: local!user, --> FirstNam,LastName
expression: fv!item
),
choiceValues:
a!forEach(
items: local!user, --> FirstNam,LastName
expression: fv!item
),
value: local!selectedUser, --> FirstNam,LastName
saveInto: local!selectedUser,
required: true,
disabled: isnull(local!selectedDept)
),

Step3:  Using  local!selectedUser, to split firstname and lastname to get email id from same table using QueryRule.

Can anyone suggest best way to achieve above? any doubt in my query?

  Discussion posts and replies are publicly visible