I have a gallery table with checkboxes used to collect id's. The id's will then be put into a query to call our API. The empty collection is initiated on page load with:
ClearCollect(selectedIds, []);
The OnSelect for the checkbox is:
Collect(selectedIds, ThisItem.Id);
I get a table with :
Value |
123 |
456 |
I then have to create a query string like so:
CustomConnectorCall.getData(query:"query{GetData(where:{ids:{eq: ["123", "456"]}}){...}}")
I know I'll have to do some form of string concatenation but how can I parse through a collection of unknown quantities to add to this string? In code, I would just write a for loop but I'm not sure how to do that in PowerApps. Thanks!
Solved! Go to Solution.
The Concat() function is exactly what you are looking for. This should work:
Concat(selectedIds, Value & ",")
EDIT: The only issue is there will be a trailing comma at the end. And I now see you custom string you need is a little more complex. Perhaps something like the below.
Concat(selectedIds,Char(34) & Value & Char(34) & ", ")
Take a look here for the Microsoft article about Concat() and Concatenate(): Concat and Concatenate functions in Power Apps - Power Platform | Microsoft Learn
The Concat() function is exactly what you are looking for. This should work:
Concat(selectedIds, Value & ",")
EDIT: The only issue is there will be a trailing comma at the end. And I now see you custom string you need is a little more complex. Perhaps something like the below.
Concat(selectedIds,Char(34) & Value & Char(34) & ", ")
Take a look here for the Microsoft article about Concat() and Concatenate(): Concat and Concatenate functions in Power Apps - Power Platform | Microsoft Learn
@JasonWS Yup! That worked for me. I was able to add the quotes around each item after reading the docs. I wasn't aware concat would smash a table like that but it works perfectly. Thanks!