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
)

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    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")
      )
    )

  • 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
    )

  • +1
    Certified Senior Developer
    in reply to swapnar6405

    HI , 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
    )

  • +1
    Certified Lead Developer
    in reply to swapnar6405

    if "rule!AA_getMembers()" is performing a query, then the data it returns will be wrapped in the "list of variant" type, regardless of whether certain fields are plaintext or not.  The first thing to try would be the code suggestion Gopalk already posted, which basically wraps the "email" query results in the "emailAddress" data type first, and does the same with the Admin Emails list, before trying to union them together.  Another technique to cast an array of any type (string) to an array of text is to (alternatively) wrap it in "toUniformString()", which handles an array of text.