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 / Unable to change the v...
Power Apps
Unanswered

Unable to change the value of a variable inside ForAll

(0) ShareShare
ReportReport
Posted on by 3,514

I have the following formula:-

 

Set(varXML,"");
ForAll(Colrow As _item,
varXML=varXML+
"<Item>
<ArticleInput type=""System.String"">"+_item.Article+"</ArticleInput>
<ArticleDescription type=""System.String"">"+_item.Description+"</ArticleDescription>
<ArticleReturnable type=""System.String"">"+_item.Returnable+"</ArticleReturnable>
<Qty type=""System.Double"">"+_item.Qty+"</Qty>
</Item>";
));

 

where i am trying to append the text of a variable named varXML inside ForAll, but i am getting an error on the "varXML=varXML".. any advice?

Thanks

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

    ForAll is not a For Loop!!  It is a function that returns a Table of records.

    However, your formula needs the Concat function, not a loop.

     

    Set(varXML, 
     Concat(Colrow,
     "<Item>
     <ArticleInput type=""System.String"">" & Article & "</ArticleInput>
     <ArticleDescription type=""System.String"">" & Description & "</ArticleDescription>
     <ArticleReturnable type=""System.String"">" & Returnable & "</ArticleReturnable>
     <Qty type=""System.Double"">" & Qty & "</Qty>
     </Item>"
     )
    )

     

    I hope this is helpful for you.

  • johnjohn123 Profile Picture
    3,514 on at

    @Randy  ok thanks now i tried this formula, to add pre & post text to the concat, as follow:-

     

    Set(varXML,"<?xml version=""1.0"" encoding=""utf-8""?><RepeaterData><Version /><Items>"+Concat(Colrow,
    "<Item><ArticleInput type=""System.String"">" & Article & "</ArticleInput><ArticleDescription type=""System.String"">"&Description & "</ArticleDescription><ArticleReturnable type=""System.String"">" & Returnable & "</ArticleReturnable><Qty type=""System.Double"">" & Qty & "</Qty></Item>")+"</Items></RepeaterData>");

     

    but i got incompatible type error

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

    Yes, you cannot add text to text.  The plus (add) operator is only valid on numbers.

     

    You need to use the ampersand character to join your text.  You had this in your original post and I corrected it in the formula I provided.

    So, with the new addition, the formula is:

    Set(varXML,
     "<?xml version=""1.0"" encoding=""utf-8""?><RepeaterData><Version /><Items>" & 
     Concat(Colrow,
     "<Item><ArticleInput type=""System.String"">" & Article & "</ArticleInput>
     <ArticleDescription type=""System.String"">" & Description & "</ArticleDescription>
     <ArticleReturnable type=""System.String"">" & Returnable & "</ArticleReturnable>
     <Qty type=""System.Double"">" & Qty & "</Qty></Item>"
     ) & 
     "</Items></RepeaterData>"
    )

    Take note of the & character and not the +

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard