37
Views
5
Comments
Solved
Use result of SQL Query in dropdown
Question

Hi,

I have a "Fetch Data from other sources" with SQL Query, as it doesn't look like i can do a "NOT EXISTS" in aggregated query.


The result will be prsented in a dropdown, but I'm having difficulties showing it.




How can I get this fixed? What am I missing? I get an error as you see ,as it want it as a "List" and not DataAction1.User. No mather what I'm setting the out variable on DataAction1 to, "List" seems to never be an option on the dropdown.

Thx for help!

Solution


Hi Kristian, 

Please follow the below steps :

1) Open the dropdown of "Data Type" and select the "List" like the below mentioned snip.


2)Tap the "User" and select it.



It will work.

Thanks & Regards,

Sudip Pal

Hi Kristian,

first off for your current struggles with the dropdown :

the output from the DataAction should be defined appropriately : it has to be a list (in your case of user, I think) to be able to use it as source for a dropdown.

I'm not sure what I'm looking at in the Set Out1 image

  • the first assignment is assigning the result of the sql to itself, that's pointless
  • the second is assigning a single user output variable to the 'current' row of the list that comes out of the sql, which would be the first record when doing that directly after the sql executes

So change the output from User to Users : type = list of user, and then your assign can be 

Users = GetUsersNotMember.List

Above should already fix it for you and make it work.

But you can get the same result from an aggregate, you don't have to use an sql widget :

in the source section of your aggregate, you'll have user and userdistrict, and you'll have a 'With Or Without' join between them, where the join condition should be :

User.Id = UserDistrict.UserId and UserDistrict.DistrictId = VarDistrictIdentifier

Then in the filter section, add filter

UserDistrict.Id = NullIdentifier()

That should give you the same result : those users that do not have a connection with a given district defined by VarDistrictIdentifier

Dorine

Champion

Hi Kristian,

Drop down always accept list data type in list field of it.

In your case you are passing user data please convert user data type into user list.

Best

Arun

Hi Kristian,

To resolve this error you just need to convert your DataAction1 output (User) to a list of Users and then you can map to the dropdown list.

always remember that the dropdown always takes a list of records.

Hope this will solve your query.

Solution


Hi Kristian, 

Please follow the below steps :

1) Open the dropdown of "Data Type" and select the "List" like the below mentioned snip.


2)Tap the "User" and select it.



It will work.

Thanks & Regards,

Sudip Pal

Thank you all for your help. Sudip Pal, that helped me a lot, changing it to a List.

Trying to understand Outsystems more, this helps a lot.

I wish you all a great day.


Kristian

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.