Accessing the value of a text input field in a listview

Hello,

I am building an internal dashboard for a mongo DB. I want to use as well that dashboard to insert new documents in the MongoDB. For this I have build a form with a listview:

Here is an example document that I need to construct and insert it later into the DB.

{
"relatedOe": {
"flemming": {
"name": "flemming",
"sevDeskContactId": "11111111",
"userCount": 26,
"lastUpdate": "2023-07-30 20:20:58",
"webinarFlatrate": true,
"createInvoice": true,
"dateOfActivePayment": "2023-07-21 00:00:00"
}
},
"name": "Flemming GbR",
"aggregatedInvoice": false,
"dateOfActivePayment": "2023-07-21 00:00:00",
"createInvoice": true,
"priceModel": "Fixed",
"priceKey": "default",
"webinarPriceKey": "default",
"aggregatedUserCount": 26,
"id": 101,
"dateCreated": "2023-07-21 00:00:00"
}

I must be able to create several objects within "relatedOe" within one document, depending on the available number of rows in the listview. So for example

{
"relatedOe": {
"flemming": {
"name": "flemming",
"sevDeskContactId": "11111111",
"userCount": 26,
"lastUpdate": "2023-07-30 20:20:58",
"webinarFlatrate": true,
"createInvoice": true,
"dateOfActivePayment": "2023-07-21 00:00:00"
},
"flemming1": {
"name": "flemming1",
"sevDeskContactId": "11113331111",
"userCount": 26,
"lastUpdate": "2023-07-30 20:20:58",
"webinarFlatrate": true,
"createInvoice": true,
"dateOfActivePayment": "2023-07-21 00:00:00"
}
},
"name": "Flemming GbR",
"aggregatedInvoice": false,
"dateOfActivePayment": "2023-07-21 00:00:00",
"createInvoice": true,
"priceModel": "Fixed",
"priceKey": "default",
"webinarPriceKey": "default",
"aggregatedUserCount": 26,
"id": 101,
"dateCreated": "2023-07-21 00:00:00"
}

In order to do this I need to access the values inside the text INputs of the listview. I tried with: listView1.data[0].textInput2.value
But it is not working?

How an I access that values?

Best regards

Try using i
listView1.data[i].textInput2.value

Hey @leonK-DI as @ScottR mentioned i is likely the way to go here, but I believe the data lives in textInput2[i].value.

Depending on where you are trying to reference this, i is likely not defined. I'd recommend using a JS query to construct the object that you want to send to Mongo. You can loop through the textInput values and place them in the appropriate spots, then send the results of that JS query as the document in your Mongo query. Let me know if you are still having issues, or have trouble setting that up.

thanks. the actual solution is "textInput2[i].value". Why is that not properly documented somewhere?

1 Like

Thanks for the feedback @leonK-DI, I'll submit a request for additional documentation here. In the interim, if you ever trying to figure out the proper syntax, the state panel is a great way to see the data structure of the components.
Components in a listview are organized as an array of objects, which each object being the traditional single component object, which contains the value property.

2 Likes