nevil
March 14, 2020, 1:48pm
1
This might be a silly question, but I cannot figure out how to get only the value of the “set value” called product_id, to the higher level.
Using {{repeat3}} outputs this:
{
"product_id": [
{
"product_id": "7065f342-76d3-4776-ab66-28e6e65c40cc"
}
],
"amount_expected": 1
}
While what I want is this output:
{
"product_id": "7065f342-76d3-4776-ab66-28e6e65c40cc",
"amount_expected": 1
}
I have also tried {{repeat3.product_id}} but that produces NULL.
George
March 14, 2020, 2:08pm
2
a repeater iterates through all the data and creates a new array/table alike data.
As there are many records in the array, you normally don’t access them just by one - you have to iterate again and do something with each record.
If you really know which record you want you can use an array index [num] to get it. Indexes are zero based. So counting starts with 0
To get the product_id from first record n your case it will be: {{repeat3[0].product_id}}
1 Like
nevil
March 14, 2020, 2:11pm
3
That did it!
The repeater was a bit “overkill” because the API call only returns 1 result, but otherwise I could not get that single value, or could I?
nevil
March 14, 2020, 2:13pm
4
Also, do you maybe still think that there is an improvement in the UI to be made there? That the values of a repeater are still available through the UI like so:
Teodor
March 14, 2020, 2:22pm
5
Why not try to access it directly then, if you don’t need the repeat. Should be something like:
{{qls_get_product.data.data[0].product_id}}
nevil
March 14, 2020, 2:28pm
6
Ah yes, that’s even better. Works great.
This might be well known for coders, but I’m not aware of those things since it’s not accessible through the UI. Maybe nice to make it available through the UI also
Maybe we could have a tick box on api action indicating it will get a single result; then it would be treated like a single db query.
1 Like
George
March 14, 2020, 3:06pm
8
The API results depend on the schema the api returns and if that is an array you have to access it as array