Skip to main content
swapnar6405
Known Participant
Apr 19, 2023 8:42 PM UTC
Solved

How to pull email address of the users who are part of any specific Appian group.

Hi,

I was able to pull list of users from the group call "AA ADMIN" by using a contact "AA_ADMIN".

Now, is there a way I can pull the email addresses of these users.

Any advises please.

a!localVariables(
  local!listOfUsers: getdistinctusers(togroup(cons!AA_ADMIN)),
  local!listOfUsers
)

gopalk2865
Participating Frequently
Apr 20, 2023 5:25 AM UTC

HI swapnar6405, Can you try below updated code?

a!localVariables(
  local!membersEmail: toemailaddress(index(
    rule!AA_getMembers(
      key: {1,2,10},
    ),
    "email"
  )),

  local!adminUsers: a!groupMembers(group: cons!AA_ADMIN, memberType: "USER"),
  local!adminUsersEmail:toemailaddress(a!forEach(
    local!adminUsers,
    user(fv!item, "email")
  )),
  local!emailList: union(
      local!membersEmail,
      local!adminUsersEmail,
    ),
  local!emailList
)

4 replies

mikes0011
Brainy
Apr 19, 2023 9:21 PM UTC

I'd prefer the newer OOB function, a!groupMembers()...

a!localVariables(
  local!userList: a!groupMembers(
    group: cons!AA_ADMIN,
    memberType: "USER"
  ),
  
  a!forEach(
    local!userList,
    user(fv!item, "email")
  )
)

The Expression Guru
swapnar6405
Known Participant
Apr 20, 2023 1:49 AM UTC

Mike,

I would like to concatenate of email address of two different variables. When I try to perform union of two local variables, I am encountering an issue.

First local variable "local!membersEmail" of type "List of Variant" and second variable "adminUsersEmail" is of type List of Text String.

Is it advisable to convert first variable to tostring() 

a!localVariables(
  local!membersEmail: index(
    rule!AA_getMembers(
      key: {1,2,10},
    ),
    "email"
  ),

  local!adminUsers: a!groupMembers(group: cons!AA_ADMIN, memberType: "USER"),
  local!adminUsersEmail: a!forEach(
    local!adminUsers,
    user(fv!item, "email")
  ),
  local!emailList: toemailaddress(
    union(
      local!membersEmail,
      local!adminUsersEmail,
    )
  ),
  local!emailList
)

gopalk2865
Participating Frequently
Apr 20, 2023 5:25 AM UTC

HI swapnar6405, Can you try below updated code?

a!localVariables(
  local!membersEmail: toemailaddress(index(
    rule!AA_getMembers(
      key: {1,2,10},
    ),
    "email"
  )),

  local!adminUsers: a!groupMembers(group: cons!AA_ADMIN, memberType: "USER"),
  local!adminUsersEmail:toemailaddress(a!forEach(
    local!adminUsers,
    user(fv!item, "email")
  )),
  local!emailList: union(
      local!membersEmail,
      local!adminUsersEmail,
    ),
  local!emailList
)