Skip to main content
swapnar6405
April 19, 2023
Solved

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

  • April 19, 2023
  • 4 replies
  • 0 views

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
)

Best answer by gopalk2865

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
April 19, 2023

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
April 20, 2023

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
April 20, 2023

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
)