Hello, 

I am working on a project where i have an user, idea and opinion table. 

To prefent a user to supply more than 1 opinion i want to check is the userID AND the ideaID are both in an opinion row.

How can i do that?


Thanks for helping!

Hi Stan.

Have you tried doing the courses? The Developing OutSystems Web Applications is a great place to start.


This looks like a case for the Data Queries video.

Assuming you have an Idea page where you have the IdeaId and you get the UserId from Session, the Advanced SQL query would be something like

SELECT Opinion.*

FROM Opinion

WHERE Opinion.IdeaId=@IdeaId AND Opinion.UserId=@UserId

where you pass the @IdeaId and @UserId as input parameters.

Or an Aggregate with sources Opinion and two filters Opinion.IdeaId=IdeaId and Opinion.UserId=Session.UserId


and just see if the list is empty because if that UserId and IdeaId are already on a row, that Opinion has been given before.

Nuno Reis wrote:

Hi Stan.

Have you tried doing the courses? The Developing OutSystems Web Applications is a great place to start.


This looks like a case for the Data Queries video.

Assuming you have an Idea page where you have the IdeaId and you get the UserId from Session, the Advanced SQL query would be something like

SELECT Opinion.*

FROM Opinion

WHERE Opinion.IdeaId=@IdeaId AND Opinion.UserId=@UserId

where you pass the @IdeaId and @UserId as input parameters.

Or an Aggregate with sources Opinion and two filters Opinion.IdeaId=IdeaId and Opinion.UserId=Session.UserId


and just see if the list is empty because if that UserId and IdeaId are already on a row, that Opinion has been given before.

Thanks , but i already figured it out by using the listAny action


Watch for performance issues. For that you need to load the full table and apply the conditions. If your site has thousands of opinions, it can be heavy.

If you already have a subgroup of the table in memory - for instance, the page preparations got all the Opinions with IdeaId - yes, you can apply one extra condition to check on the UserId. But it is not ideal.

Good point! I will keep that in mind!