web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Substitute inside ForAll
Power Apps
Answered

Substitute inside ForAll

(0) ShareShare
ReportReport
Posted on by 565

Hi all,

 

I have a SharePoint list with names of people and some columns ("Product" by example), and I have a button that creates messages to send based on this list of people, so the body of the message is taken from a text template and I want to replace some tags inside the text template for values of the user:

 

ForAll('PAX INFORMATION',
Patch('Messages', Defaults('Messages'),

{Title:ThisRecord.PaxName,
Phone:ThisRecord.Mobile,
Body:Substitute(LookUp('PUM Template Messages', Lang = Language , Message), "#PRODUCT#", ThisRecord.Product),
Language:ThisRecord.Lang,
Status:"Pending"}));

 

The message is created but with the default text template message, the Substitute is doing nothing here.

How can I solve this issue?

 

Thanks in advance,

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    155,927 Most Valuable Professional on at

    Hi @EmilioRoqueta69 , 

    I am making a couple of assumptions here as to where your data is located, but try this

    Patch(
     'Messages',
     ForAll(
     'PAX INFORMATION' As _Pax,
     {
     Title: _Pax.PaxName,
     Phone: _Pax.Mobile,
     Body:
     Substitute(
     LookUp(
     'PUM Template Messages', 
     Lang = _Pax.Language,
     ).Message,
     "#PRODUCT#", 
     _Pax.Product
     ),
     Language: _Pax.Lang,
     Status: "Pending"
     }
     )
    )

    Also, ForAll() is not designed to be a Loop, although it can work this way with considerable performance penalty as it does an individual Patch for each record. ForAll() creates a Table, which can be patched in one action provided its content is correct. For new records, this is simply a Table with field names and field types matching the list.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • EmilioRoqueta69 Profile Picture
    565 on at

    You are amazing man, a great contributor to this community.

    It is works!

    Thank you so much!!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 342 Most Valuable Professional

#2
11manish Profile Picture

11manish 234

#3
Valantis Profile Picture

Valantis 187

Last 30 days Overall leaderboard