Home > Forum > Data sources > Item list from SQL query with filter

Item list from SQL query with filter
0

Hi,
Sorry for my lack of knowledge but I've just installed WEBCON 2 days ago.
Please help!
I want to add in a item list rows from a SQL database but:
Querying data is ok.
I want to select a product name based on that query (from a Choice field) and get the correspondent price from the query...
Also my query is based on another field as a filter
When I change the value of that filter, the list of products should change but it doesn't.

And also, I can't get the price for the product...

If I change the filter first, the product list changes but, when I change again the filter, the product list is the same...
Thank you.

MVP

Hi Cristian,

welcome to the community. :)

Let me phrase this in my word, so that you can verify whether I understood it correctly.

1. You have a "product group" field, where you select one "product group".
2. Depending on this. the rows in the item list should be updated.

You could achive this by defining the "Initialization" on the item list
https://docs.webcon.com/docs/2023R2/Studio/Process/Attribute/Basic/Itemlist/ILConf/ILConf_Init/#2-initialization

In addition you could trigger the "Initialization" in the "On value change" area of the "Product group" field. This function is available in the form rules. I currently don't have access to a system so I can't copy it. It's somewhere in the "Item list" node.

While searching for this I found an older topic which would be similar to your case, as far as I understood it:
https://community.webcon.com/posts/post/javascript-functions-in-the-html-form-fields-part-2/167

Regarading the price.
I currently have no idea, where your data is comming from, and why your query would retrieve some fields but not others.


Regardless of this, I'm wondering what the useres should do with the rows in the item list.
If it would only be for displaying the products a data table would be more approrpriate.

Best regards,
Daniel

In reply to: Daniel Krüger (Cosmo Consult)

Hi Cristian,

welcome to the community. :)

Let me phrase this in my word, so that you can verify whether I understood it correctly.

1. You have a "product group" field, where you select one "product group".
2. Depending on this. the rows in the item list should be updated.

You could achive this by defining the "Initialization" on the item list
https://docs.webcon.com/docs/2023R2/Studio/Process/Attribute/Basic/Itemlist/ILConf/ILConf_Init/#2-initialization

In addition you could trigger the "Initialization" in the "On value change" area of the "Product group" field. This function is available in the form rules. I currently don't have access to a system so I can't copy it. It's somewhere in the "Item list" node.

While searching for this I found an older topic which would be similar to your case, as far as I understood it:
https://community.webcon.com/posts/post/javascript-functions-in-the-html-form-fields-part-2/167

Regarading the price.
I currently have no idea, where your data is comming from, and why your query would retrieve some fields but not others.


Regardless of this, I'm wondering what the useres should do with the rows in the item list.
If it would only be for displaying the products a data table would be more approrpriate.

Best regards,
Daniel

Thank you for the answer.
I've changed a little bit the whole thing...
I've created some choice fields that grab the data from the SQL database.
Category, Product, Price and Quantity.
Now I need a way to add them on an item list row...and calculate the value column...
How can I do that?
Thanks.

MVP
In reply to: Cristian Balaur

Thank you for the answer.
I've changed a little bit the whole thing...
I've created some choice fields that grab the data from the SQL database.
Category, Product, Price and Quantity.
Now I need a way to add them on an item list row...and calculate the value column...
How can I do that?
Thanks.

Hi Christian,

could you move the choice fields into the item list row? This would make it far easier, you could even activate a "modal dialog" style of entering the data, so it would have a similar look and feel as normal fields.

Here's a short overview on how I would have done it. The numbers are referring to the screenshots.
1) The modal dialog can be activated by enabling "Single row editing" in the advanced configuration of the item list.
2) The "product" field is filtered by the category. Each product has a price and this gets copied to the price field. It's imported to choose another either Choose (picker) or autocomplete and not the first one. Otherwise you can not add more fields /rows using the + icon.
3) The amount field is of type calculated field.
4) The total of the item list is copied to an own column using the 'Totals control' tab in the advanced configuration of the item list.

Best regards,
Daniel