Pass Records to Flow Record Collection Variable

I’m launching a Salesforce flow with a Skuid button, and I’d like to be able to pass all records in a model into a Record Collection variable. Is there a way to do this? I can see how to pass a single record using a merge variable, but not sure whether there is merge syntax to pass all records in a model.

Hey @Elissa_Bradley and welcome back!

If you would like to pass all records to the model, you could do something like:

Be sure to replace modelName with your actual model name.

You can find more info:

Thank you! It’s good to be back.

Just tried that syntax, but I’m getting an error in the Chrome console that I can’t interpret. I am on an old version of Skuid (12.2.9)… maybe I should upgrade before I try to track this down.

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Array'
    |     index 0 -> object with constructor 'Object'
    |     property '__skuid_record__' -> object with constructor 'Le'
    |     property '_model' -> object with constructor 'Ue'
    --- property 'data' closes the circle 

No prob @Elissa_Bradley !

Hmmm looking at the error, can you verify how you are passing the data? it seems to be a mismatch in the data type( array → object).

One solution you can try to do is loop through the rows and merge each value in a comma-separated list like so(see example):


More information can be found in the doc:

I am using a Record Collection Variable in my flow (which is looking for Case records to be passed in), and was trying to use this merge syntax to pass in records: {{$}}.

I tried creating a Collection Variable instead of a Record Collection Variable in my flow, but trying to populate that using the same merge syntax ({{$}}) resulted in the same error.

I did try out the latest merge syntax you provided – {{#$}}{{Id}}{{^Record.isLast}},{{/Record.isLast}}{{/$}} – and I can use that to populate the Collection Variable, but that syntax puts a comma after the last record in the list, like this:

CasesToCoverArray = [5000h00001lN4l6AAC,5000h00001lN4l6AAC,]

If I take out the comma in the merge syntax and test with a single record, I’m successful. So - any idea why the output has that final comma??

Hey @Elissa_Bradley , here is a solution that should work:

  1. Create on UiOnly formula field (call it something like IDListCommas ) with the merge that adds the trailing comma: {{#$}}{{Id}},{{/$}}
  2. Create a second UiOnly formula field (call is something like IDList ) that references the first field, but trims the trailing comma: LEFT({{IDListCommas}},LEN({{IDListCommas}}-1))

Splitting it into two different formulas cuts down on evaluations (i.e. you only have do loop over the data and build the string of IDs once)

Thanks for sticking with me on this @anon57098112! (And - appreciate that this cuts down on evaluations; that’s the whole reason I’m passing the data to a flow… was having issues with volume using a snippet and think I can simplify in a flow…if I can pass in a collection!)

So - I’m still getting a weird error. I added the UI-only fields to the SelectedCases model but get this: 1. Syntax error in formula field “IDListCommas” at line 1, column 3: Expected [ \x0C\n\r\t\x0B - ] but “#” found…

I also tried creating a UI-Only model to hold these fields, but that results in the same error.


Hey @Elissa_Bradley and no worries!

Can you share your Model XML that contains the formulas so we can take a look and see what is happening?


Here’s the model:

	<model id="SelectedCases" limit="50" query="false" createrowifnonefound="false" sobject="Case" datasource="salesforce">
			<field id="Subject"/>
			<field id="Id"/>
			<field id="IDListCommas" uionly="true" displaytype="FORMULA" length="255" label="IDListCommas" ogdisplaytype="TEXT" readonly="true" returntype="TEXT">
			<field id="IDList" uionly="true" displaytype="FORMULA" length="255" label="IDList" ogdisplaytype="TEXT" readonly="true" returntype="TEXT">

@anon57098112 , coming back to this again… any ideas on my XML?

Hi @Elissa_Bradley,
I think I may have a solution for you. Unfortunately, the “truthy/falsy” merge syntax (#$Model…,^$Model… and /$Model…) that allows you to loop through the rows in a model is not supported in UI only field formulas which is why you are getting the syntax error. Good news though - I think the original merge syntax you were trying can be updated to leave out the final comma.

Something like this should do the trick:

  • Add a UI-only field to your Selected Cases model called something like “isLast”. Make it a formula field that results in a checkbox with the formula value {{Record.isLast}}
  • Then reference that UI-only field in your merge syntax logic to leave out the last comma in the list: {{#$}}'{{Id}}'{{^isLast}},{{/isLast}}{{/$}}

That should give you a comma separated list (without the final comma) to use for your collection variable.

Hi Elena,
Thank you for this! I played around with your syntax, then realized I could pass a text string into my flow and parse out the IDs (and remove the final semi-colon) in the flow, which ended up working better for me because I couldn’t figure out how to get my flow to handle the collection variable. I had an easier time passing in a text string.

Now I have a question about the {{$}} syntax. I have a table on the screen where users can select rows. On the table I have an action “adopt rows into model” / “rows in context” into a new model - my SelectedCases model. Then, I show a pop-up that is designed to show the user what she’s selected. The table shows the selected cases nicely.

The issue is that the merge syntax is passing the first of the selected ID multiple times (one time for each item I selected.) I know this because I’m stamping the user record with output value of the merge syntax, just to understand what is happening. So, if I pick three cases, the first of which has ID 5005C000007LvjeQAC, the following is passed via the merge syntax:


This is the merge syntax that i’m using:


Any ideas what might be going on here?

I did notice that if I used this merge syntax in a rich text field and used “SelectedCases” as my context model and checked “do not run template on each row”, the output value looked correct.

Hi Elissa,

Glad that helped!

It looks like the merge syntax that is used to iterate over each row gives unexpected results (showing data from the first row for every row) when it is run from a component that references the same model that you are looping through in the merge syntax. So if you’re triggering the flow and passing in merge syntax from a button, try updating the model on the button set component to a model other than SelectedCases, or even leave it blank and that should do the trick.

Elena, thanks again!

I changed the model (on a Page Title Component, which is where my button is displayed) to an unrelated model. But now the merge syntax is sending a row from the unrelated model - the first row for every row selected! It seems that the merge syntax is referencing the underlying model and grabbing the first row, one time for each selected row.
Very strange!! Bug?

And - I figured it out! I needed to put the button in a Button Set - not a page title - and that did the trick. For others trying to pass multiple records into a flow variable:

I am using a button on a button set to launch a Salesforce action.
My variable is a text variable that I’m parsing within my flow.
Merge syntax for my text variable: {{#$}}{{Id}};{{/$}}

Awesome! Glad to hear you got it working.