This can be done with a simple flow formula: If your original source data is in a Text Collection named DocNamesCollection
with the content...
Payload1
Payload2
Payload3
Payload4
...just create a flow formula DocNamesCollectionCsv
of type text that reads
{!DocNamesCollection}
This formula will result to
[Payload1,Payload2,Payload3,Payload4]
Apparently you want to get rid of the []
, then change the above text formula to
MID({!DocNamesCollection}, 2, LEN({!DocNamesCollection}) - 2)
which will deliver the desired result of
Payload1,Payload2,Payload3,Payload4
If you want to count the number of elements in your collection, just define a Number variable DocNamesCount
and use it in an assignment element as follows:
Variable=DocNamesCount | Operator=Equals Count | Value={!DocNamesCollection}
If your source collection happens to come from a record collection, e.g. build a list from Account.Name out of a GetRecords on Account, you can use the Transform element to convert the Account collection into a text collection and do same as above.
Important note:
- This will fail if your payload contains
"
as string delimiters will not be escaped.
- This will fail if your payload contains comma
,
as the approach cannot distinguish between payload comma and list comma.
If you need to deal with such special cases and/or want to have the string delimiter or the field delimiter configurable, I suggest my BLOG post with a detailed explanation on how to enhance the formulas to achieve this: How to Concatenate a Collection of Strings to a Comma-Delimited String in Salesforce Flow