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

Community site session details

Session Id :
Copilot Studio - General
Answered

Co-Pilot Topic Designer: Power Fx Function for Adding Record to Table in Loop?

(0) ShareShare
ReportReport
Posted on by 47
Hi all, 
 
I'm building some custom logic to send an array of files uploaded to my agent in an HTTP request to either an Agent Flow or Power Automate flow for async processing. 
 
I'm facing an issue with adding a record to my array variable. See attached image. What I've done:
  1.  Set a Table variable "FilesToSend" as an empty array
  2.  Loop over my "System.Activity.Attachments" table
  3.  Modify my "FilesToSend" table by adding a current record
    1.  Now instead of just adding the record I want to append it as an object like: 
      {
          fileName: CurrentItem.Name,
          fileUrl: CurrentItem.ContentUrl,
          contentType: CurrentItem.ContentType
      }
 
However, to my knowledge there are no PowerFx functions available in the Co-pilot topic designer for Set or Collect (looking at both the auto-complete and the formula references here).
 
Has someone faced this before and can advise me?
 
Thanks!
Wes
Categories:
I have the same question (0)
  • Verified answer
    WC-12111705-0 Profile Picture
    47 on at
    Co-Pilot Topic Designer: Power Fx Function for Adding Record to Table in Loop?
    I have solved my own question! To accomplish this:
    1. Click + > Set a variable value
    2. Select the current item within the loop
    3. You can create objects (or records) as variables, so go to Formulas and expand
    4. Create a JSON structure for your record { filename: Topic.CurrentItemName, ... }
    5. Click + > Modify items in a list
    6. Select your table variable set outside the loop
    7. Select "Change Type" to "Add Item" 
    8. Select the variable record you just created
    In this way you can add records to a custom table variable after manipulating them for any format you wish (i.e. preparing them in a specific structure for an HTTP request).  

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

Coming soon: forum hierarchy changes

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

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 356 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 345 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 57 Moderator

Last 30 days Overall leaderboard