Dynamic data not displaying having to include [0]

Hi,
Its strange but I am having difficulty inserting Dynamic data from a server connect, and I am having to insert [0] to make it appear.
For example:
‘’ {{sc_sysparam.data.sysparam[0].sysparam_id}}’’ with display the correctly, but not
‘’ {{sc_sysparam.data.sysparam.sysparam_id}}’’
The dynamic data picker inserts ‘{{sc_sysparam.data.sysparam.sysparam_id}}’

Any idea why this is happening?

A standard (multi record) query returns an array hence the need to specify the index, [0] referencing the first element.
If your query only returns a single record use a single query if possible and the index reference will not be needed

1 Like

Thanks very much for the explanation. It makes sense.
Just wondered why on that particular page of code it wasn’t entering the [0] and I had to do it manually.
But thanks for replying and clarifying.

In a server (api) action it is normal to parse the array within a repeat where the index is not required.

You just found a Wappler bug then :slight_smile:

If wappler was to add the index to a returned array how could it possibly know which element is wanted?
Not convinced this us a bug rather than an issue with technique, single queries were designed for exactly the purpose to get around this issue, before then queries had to be wrapped in a repeat to select individual records.

Wappler does/did this already with index 0 if you selected a variable of type array, the bug is in the identification of the variable type

I do understand your point though :slight_smile:

well although adding [0] will help to get the first element of an array, this is rarely what you want when you have multiple records.

You always usually want to make a repeater first to go through all the records, and then display them.

If you really want just a single record then you should use the single record query.

Btw I did test the inserting of a array value from server connect and it does insert [0] per default with me…