Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Substitute inside ForAll

(0) ShareShare
ReportReport
Posted on by 509

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:
  • EmilioRoqueta69 Profile Picture
    509 on at
    Re: Substitute inside ForAll

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

    It is works!

    Thank you so much!!

  • Verified answer
    WarrenBelz Profile Picture
    147,950 Most Valuable Professional on at
    Re: Substitute inside ForAll

    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

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 770 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 494

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 399