Not Exit from a loop
Hi to all!
i have got this loop on a formula:
let images := response.result.images;
let coverimageLink := "";
let foundImage := false;
for i in images do
if (i.type = "primary" or i.type = "secondary") and not foundImage then
let coverimageLink := i.resource_url;
coverimage := coverimageLink;
foundImage = true
end
end
Copy
it extract data from a Json like this:
i am trying to extract the first resource_url found independently if "primary" or "secondary" (but it has to be the first), but for some reason I can not understand the formula doesn't break the loop at the first resource_url found and the output got is the last:
3 replies
-
If you only need the first item in the array you should just use the item() function.
item(images, 0).resource_url
The only for-loop style you can break out of is this one and you do it by changing the value of i.
-
i had to "reParse" the JSON to use the item function.
And this:
let images := text(response.result.images);
let images := parseJSON(images);
let coverimageLink := item(images, 0).resource_url;
coverimage := coverimageLinkworks in an excellent way
THANK YOU a lot Sean
Content aside
- Status Answered
- 1 yr agoLast active
- 3Replies
- 102Views
-
2
Following