Hi.
I'm having difficulty accessing data in a collection, via PowerApps.
I create the collection with this:
Collect(coll15,mt.GetAnswers("3b....da","application/json",{question:"eco"}))
Using Developer Tools -> Network tab -> Response body - the following JSON data is returned:
{
"answers": [
{
"answer": "This is the answer",
"questions": [
"Private vehicle eco renewal"
],
"score": 82.901087775826454
}
]
}
The collection is created.
I then add a gallery control to my page - however the only options I have to bind to the labels are: ThisItem.Value
If I try to enter ThisItem.Value.answer I get the error: Invalid use of '.'
If I enter ThisItem.answers.answer I get the error: Invalid name
Is there any way for me to access the answer text within the collection?
Thanks for any help,
Mark
I wasn't aware you could create a Collection out of a JSON object that way. Did you look at the collection after it was created by the collect() to see how it is structured? In PowerApps Web Studio > File > Collections > Select a collection. This should show you what the collection looks (columns and rows).
Hi Jeff.
I can create a collection like this:
Collect(faqs, {
question:{answers: [{answer: "This is answer1",
questions: ["This is question 1"],
score: 93.2
}
]
}})
That then creates this:
But within Poweapps - I can't seem to reference beyond faqs.question:
So the collection is there - I just can't seem to get to the parts I need.
Thanks, Mark
Hello @marktait,
If you are still looking an answer to this,
Label1.Text = LookUp(LookUp(faqs,true,question).answers,true,Value).answer
Check your syntax in the expression you create the collection and notice when the expression LookUp(LookUp(faqs,true,question).answers,true,Value).answer, has a dot, and when a LookUp, in order to go deeper.
If you have questions I can help more.
I have a collection created, pulling data from an array. In my array, I have multiple properties in my objects, but I can't seem to get at those properties. In the below example, I'd want to get the "link" property of the "parent" object.
My array is coming in as:
[
{
"parent": {
"display_value": "123",
"link": "https://demo.com"
},
"shadow": "false",
"updated_on": "2018-12-07 10:30:52 AM",
"number": "12345",
"u_task_for": "",
"top_program": "",
"schedule_start_date": "2017-10-11 12:35:47 PM",
"state": "Draft",
"sys_created_by": "M2R",
"knowledge": "false",
"order": "",
"work_duration": "",
"short_description": "abcd",
}
]
Hello mysticode,
Does the following work for you?
LookUp(CollectionName,true, parent.link)
Thank you for your reply.
I tried this, and an error is returning. Please note that I am doing this in a gallery (not sure if that changes anything):
I loaded the JSON you supplied into a collection, colTest.
To get the value of the first item, use the following (e.g. in the text property of a label):
First(colTest).parent.link
To show in a gallery, I simply set the Gallery Items property to colTest
I then created to labels with the following text properties:
ThisItem.parent.display_value
ThisItem.parent.link
Okay, I see.
If you want to display it in a gallery, you can try:
Gallery1.Items : enhancements
Label1.Text : Parent.link
When I try to use in a Text property function:
First(colTest).parent.link
The error coming back is:
Invalid use of '.'
User | Count |
---|---|
254 | |
250 | |
82 | |
44 | |
27 |
User | Count |
---|---|
343 | |
266 | |
126 | |
61 | |
58 |