cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Usage of Concat(), inside Collect(), inside a ForAll()

Hello,

I have the following data architecture:

SourceName

Columns

SPO ListPeopleTitle, TimeWorked, Project (which is a lookup field referencing the table Projects)
SPO ListProjectsTitle, Duration, Budget
SPO ListExport listTitle, HTML Code

 

Each Project can have any number of people working in it. I need to export all the projects to a PDF, either one by one, or in bulk.
In "One-by-one" mode, I create a HTML Code and use PowerAutomate to create the .html document and convert it to PDF. The code for the HTML is as follows:

 

Concatenate(
    "
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h2 style=""text-Align: center"">
	<strong>
		 Project Birth Certificate
	</strong>
    </style>
</h2>

<p>
	<strong>
    	<br />
		 Project Name: </strong>";
    GallerySelectedItem.Title;
    "
	
</p>
<p>
	<strong>
	<br />
		 Participants: </strong>	<br>";
    Concat(
        Filter(
            People;
            Project.Value = GallerySelectedItem.Title
        );
        Title & " - Time Worked is " & TimeWorked "<br>"
    );
    "
)

 


And it works beautifully. GallerySelectedItem is a variable that holds the item selected in the gallery of all projects (duh). I typed that formula inside the HtmlText property of the HTML Text viewer of PowerApps. It correctly filters the people who participated in GallerySelectedItem Project. I then send the contents of the HTMLText to the PowerAutomate flow that converts it into a PDF. 

To export in "bulk-mode", I created the following code:

 

Clear(ExportData);;
ForAll(Projects; 
Collect(ExportData;
{ 
  Title1 : Title;
  HTML: Concatenate(
    "
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h2 style=""text-Align: center"">
	<strong>
		 Project Birth Certificate
	</strong>
    </style>
</h2>

<p>
	<strong>
    	<br />
		 Project Name: </strong>";
                 Title;
    "
	
</p>
<p>
	<strong>
	<br />
        Participants: </strong>	<br>";
    Concat(
        Filter(
            People;
            Project.Value = Title
        );
        Title & " - Time Worked is " & TimeWorked "<br>"
    );
    "
)));;

ForAll(
    ExportData;
    Patch(
        'Export List';
        Defaults('Export List');
        {
            Title: Title1;
            'HTML Code': HTML
        }
    )
);;
MyExportFlow.Run()

 

We can assume "MyExportFlow.Run()" executes correctly because I receive the PDF file that was created, but without any of the participants, but all the other fields correctly.

What am I doing wrong here? On the Bulk export mode, I create a colection with two columns (Title and HTML Code) then patch it to my SPO list. This step works, but I can see that under my SPO List, there isn't anybody under the Participants field of the HTML code, even though the project name shows correctly and the PDFs are also generated correctly.

Also, I had to sanitize the name of the columns because I'm working with somewhat classified data from my company, so pardon me if some of the names are exactly what you'd expect. I can guarantee you that the sintax is right and there isn't a warning or error on this codes (because PowerApps says so LoL)

Best Regards,

Pedro.

2 REPLIES 2
Highlighted
Community Champion
Community Champion

Re: Usage of Concat(), inside Collect(), inside a ForAll()

Hi @Gaiarsa ,

Please see ### and *** comments

One thing you might try is some possible disambiguation as suggested. My indenting is also a bit out in places.

Clear(ExportData);;
ForAll(
   Projects; 
   Collect(
      ExportData;
      { 
         Title1 : Project.Title;
         HTML: 
         Concatenate(
            "
            <!DOCTYPE html>
            <html>
               <head>
                  <title>
                      Page Title
                  </title>
               </head>
               <body>
                  <h2 style=""text-Align: center"">
	             <strong>Project Birth Certificate</strong>
</style> ###                                        ***No opening <style>                                
                  </h2>
                  <p>
                  <strong><br />
		  Project Name: </strong>";
                      Title;
"  ###                                          ***quotes correct?
                     </p>
                     <p>
	                <strong><br />
                        Participants: </strong<br>";
                        Concat(
                           Filter(
                              People;
                              Project.Value = Project.Title
                            );
                           Projects.Title & 
                          " - Time Worked is " & 
& added ###                Projects.TimeWorked & "<br>"
                        );
###               </body>
###            </html>                      
              "
         )  
###   }                                ***missing closing }
   )
);;

ForAll(
    ExportData;
    Patch(
        'Export List';
        Defaults('Export List');
        {
            Title: Title1;
            'HTML Code': HTML
        }
    )
);;
MyExportFlow.Run()

 

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.

 

Highlighted
Community Champion
Community Champion

Re: Usage of Concat(), inside Collect(), inside a ForAll()

Hi @Gaiarsa 

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

 

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.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,850)