Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

On Demand Flows - Send email to selected records (Contacts)

Posted on by 50

Hi all,

I am struggling with an error that is getting the better of me!

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@outputs('Get_record')?['body/contactid']' is of type 'String'. The result must be a valid array.

All I want to do is create an On Demand Flow where we can email selected contacts with an email!

Any successful examples greatly appreciated!

Scenario:

Select contact records, run on demand flow, send email to each of them.  This was REALLY easy in Workflows, why so difficult in Flows...

Calling out to Elaiza Benitez to show me the way!!

  • LuHao Profile Picture
    LuHao 40,866 on at
    RE: On Demand Flows - Send email to selected records (Contacts)

    Hi Mark,

    Glad to hear that.

    Cheers!

  • Mark.Fletcher Profile Picture
    Mark.Fletcher 50 on at
    RE: On Demand Flows - Send email to selected records (Contacts)

    Hao,

    Thanks!! I now understand how the "Get a Row" is optional (just to grab related entity data - or do we call them tables these days?!!).

    You have verified for me the simplest of requirements, and all tests have gone well!  Amazing how we can so easily assume it needs to be more complicated..

    I think I learnt a big lesson when originally adding in "List Records"!!!!! I got hundreds of emails sent to me quoting everyone's first name!  Ha Ha!!

    Thankfully I had not gone live with it!

    Lesson learnt is "Use the RIGHT action for the task!"

    Once again thanks for your clear guidance, greatly appreciated, especially when there is NO mention of Javascript...!!

    Faith restored, thanks.

    Mark

  • Verified answer
    LuHao Profile Picture
    LuHao 40,866 on at
    RE: On Demand Flows - Send email to selected records (Contacts)

    Hi Mark,

    The "Get a row" action is not necessary, here it is used to get the Owner's first name, which is used as the last signature in the body of the email.

    If you don't need to use Owner as a signature, then you can leave out the "Get a row" action.

    The following are the simplest steps to send emails in flow.

    pastedimage1612836096456v1.png

    If you want to get the field value of Contact's related entity and add them to the email body, then we need to use the "Get a row" action to get all the fields of the record, just like I did before to get the first name from Owner (User).

  • Mark.Fletcher Profile Picture
    Mark.Fletcher 50 on at
    RE: On Demand Flows - Send email to selected records (Contacts)

    Hi Hao!

    Good to hear from you again!  Always straight forward guidance thanks.

    Can you just please verify that the "Get a Row" action has to point to the USERS table?

    I imagined it would need to get rows from the Contacts table??

    If the Table does need to be Users, could you perhaps provide me with a simple explanation behind that?

    Cheers,

    Mark

  • Suggested answer
    LuHao Profile Picture
    LuHao 40,866 on at
    RE: On Demand Flows - Send email to selected records (Contacts)

    Hi Mark,

    • In flow, the To field must be a specific email address, such as luhao@test.com.
    • In the workflow, the To field is contact records.

    This is the difference between the two of them.

    So, we need to populate the To field in flow with the value of the Email field and no longer the GUID of the contact.

    pastedimage1612752564192v1.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,564 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,651 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans