0

EDIT: enter image description here

I'm creating a flow where the users in the Group will received an email via flow based on certain conditions:

I have done the following steps:

  1. Configure start

enter image description here

  1. "Get Records" from object "Group Member"

enter image description here

  1. "Loop" through "Group Member" results

enter image description here

3.1 Use "Assignment" to add the user email address to the "Collection Variable"

enter image description here

3.3 (after last item) "Action" to send email and use the "Collection Variable" as Email Addresses (as long as the combined number of email addresses is five or fewer.)

enter image description here

Is there a way or workaround to send email individually to a user from a public group?

When I debug I see that

Result

{!User_Email} = "[]"
4
  • What is being added to User_Email? The title of that assignment seems to suggest you're adding an Id? Recipient Email Addresses expects actual email addresses that you would get from querying the user record using the UserOrGroupId from GroupMember. Commented Jun 29, 2022 at 21:53
  • i'm query the Group and for the User_Email I'm adding Email
    – Nick
    Commented Jun 29, 2022 at 22:47
  • this only works for one level Groups (what if you have groups that contain groups?) - Also - you are querying in Get Records Group but you should be querying object GroupMember
    – cropredy
    Commented Jun 30, 2022 at 0:18
  • changed it to GroupMember and in the user_email I'm adding Group.Email but still getting the empty, so what I'm trying to do is that, trying to send email to the users who are added to the Group
    – Nick
    Commented Jun 30, 2022 at 1:17

1 Answer 1

1

So, you are going to need three Get Records elements

Get Records 1

  • Query Group for yourGroupName

Get Records 2

  • Query GroupMember where GroupId = result.Id from Get Records 1

Loop

  • Build a collection variable of strings for each GroupMember where UserOrGroupId starts with 005 (meaning it is a User, not a Group)

Get Records 3

  • Query User where ID = the collection variable built in the loop. This will yield 1 or more User.Email which is what you need.

Even if you used Apex, it would take two queries because the following isn't supported on GroupMember (no support for the UserOrGroup relationship as the schema describe doesn't expose that relationship)

SELECT Id, 
     TYPEOF UserOrGroup 
         WHEN User THEN Email 
     END 
   FROM GroupMember 
   WHERE UserOrGroup.Type = 'User' AND
         Group.Name = 'yourGroupName'
5
  • when query GroupMember, you only get Id, GroupId, UserorGroupId I'm not sure where you going to define Group.Name in the GroupMember
    – Nick
    Commented Jun 30, 2022 at 14:25
  • It is a relationship (lookup) field
    – cropredy
    Commented Jun 30, 2022 at 14:26
  • I edit my question and post the screen shot.
    – Nick
    Commented Jun 30, 2022 at 14:29
  • fixed - i forgot that you can't filter on relationship fields in Get Records - see this Idea
    – cropredy
    Commented Jun 30, 2022 at 23:00
  • I'm not sure I understand when you say Build a collection variable of strings for each GroupMember.... what you mean by that do you mean create a loop? is that possible if you can put in a flow and have screen shots?
    – Nick
    Commented Jul 1, 2022 at 13:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .