How can i get this to work? Trying to use @trade inside {{multiselecTrades.value[@trade]}}
DECLARE @count2 INT;
DECLARE @trade INT;
SET @trade = 0;
SET @count2 = ({{multiselectTrades.value.length}});
WHILE @count2 >0
Begin
INSERT INTO
leadTrades(
LeadId,
TradeTypeId)
Values (@leadId,{{multiselectTrades.value[@trade]}})
SET @trade = @trade + 1;
SET @count2 = @count2 -1;
END
Hey @nroeder
Hmm I’m not sure this is possible, but I wonder if there’s another way we can do this type of looping. Are you basically trying to run this query for each value selected in the multiselect component?
Cool! Would something like this work?
http://community.retool.com/t/how-to-run-a-rest-api-query-for-each-item-in-an-array-and-return-all-results-together/2352
It basically uses the Retool query property “additionalScope” to call the target query as many times as you need and dynamically pass in each value.
Here’s a more in depth read on additionalScope!
http://community.retool.com/t/how-to-use-additionalscope-in-your-queries/13343