Display a single record without a list

Hi
I have one screen where I want to display the schedule of the logged in user.
I can create an external collection that will connect to an API, pass the logged in user id and return the user’s data as an object (not an array).
Will the external collection accept an object?
Can I then display the key values of this object directly in magic text on a screen (without connecting to a list)?
Currently, when I choose an external collection of an array via magic text, I can only display the count

You cannot do this with an external collection as stated. You have 2 options.

Using External collections.
Have your API return an array of users, with 1 item. so

[{ id: 1, username: "Me"}]

then you can place a text field onto your screen, click the vertical more button beside the name in the props, and convert it to a list, use the magic text to display the username. This will work because the list will only have 1 element so it will only display 1 text field, even though it is a list

Using Custom Actions
You can do what you want using Custom Actions on button clicks only. Using Custom Actions on Page load does not give you the ability to use Magic Text results (bug in Adalo). So when a user clicks a button you call a custom action to your endpoint to get the magic text from the results to use. This only takes an object, arrays are not supported (well, if you have a nested array you can get the first element in the array).

I hope this helps.

3 Likes

Thanks so much. I will try both approaches

I tried the first approach and it works great. However, for some reason, there is extra spacing below the converted list for some reason also I made the height in styling to be 20. I have an actual list below that text list and it shows up with quite some space below. Any ideas?

No worries. I had to set the positioning to fixed