HI,

I am a new Learner of Outsystems. I am developing a sample application in which I have a requirement to develop Like and Dislike feature to a Post. I do not get an Idea how to implement that. Could anyone help me with any fordge link for the same feature or any idea how to proceed.


Thanks

Sunil Reddy

Hi Sunil,

If you have more details than you need, or images, it would help us to understand, but I think I understand what you need...


For you to have a Post, you must have this table {Post} in your database.

To be able to click like and dislike you can create a [Like] field in your table, of the boolean type, each time a person clicks the like or deslike button, you change this variable.


Regards.

Hi Sunil,

Basically you need to two entities and between one to many relationship.

1. One Entity have three column like - Entity idenetifire and Post , UseID (user identifire)

2.second entity have - Entityidentifire , First entity identifire as foreign key, Islike,isdislike, UseID (user identifire)

3. Now when you post insert data into first entity and based on this post provide like dislike featuer.

4.When user click on Like feature insert data into Second Entity and set IsLike =True and Provide Post id

5.Do same for dislike

also you can  do one thing instead of islike/isdislike column can hold count of like and dislike


Hope this will help you.

Regards

Rahul Sahu

Solution

Hello Sunil.


If you have a Users entity and a Posts entity.
Now you create a Likes entity with:
Id
PostId (Post Identifier)
UserId (User Identifier)
Like (Integer)

You have 3 scenarios:

  • When a user clicks a clicked icon: you remove any existing entry of same userid and postid.
  • When a user likes, you remove any existing entry of same userid and postid and create one with Like=1.
  • When a user dislikes, you remove any existing entry of same userid and postid and create one with Like=-1.


To see a post's score you sum Likes of Postid.

Solution

Hi Sunil,

As pointer to your question solution, here is a tip:

1 - create a WB to place your icons thumbs up/down

2 - encapsulate them in a logical condition (consider selected / not selected)  

3 - make a link to an action so you can change the condition

Here is an example in reactive, Cheers!