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

Notifications

Announcements

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
    153,084 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard