Adding a follower button to the row action

  • 1
  • Question
  • Updated 4 years ago
  • Answered
  • (Edited)
i want to add follower button to the row action ,how can i achieve that..any help..thanks
Photo of Rizvan Ansari

Rizvan Ansari

  • 382 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
Official Response
Rizvan,
Forget what I just said about Javascript! With Skuid's new Actions Framework, you should be able to create the Follow button with no code! Here's what you need to do:

1) Create the EntitySubscription model with 2 conditions:
    (a) SubscriberId = id of the current user (Always On)
    (b) ParentId = [don't specify a value] (Filterable, default off)

Under Advanced model settings, uncheck both "Create default row if model has none" and "Load Model data on page load." Therefore, when you first load the page, this model contain no data.

2) Add your row action in the Accounts table. This row action should be type "Run Multiple Actions."

3) After specifying the action type, click on Actions.

 Add actions:
   (a) Activate & Set value of Model Condition: Set the value of the ParentId condition to the Id of the Account in the row

   (b) Create new row in Model (on your EntitySubscription model). This new row will follow your new condition on ParentId.
   (c) Save Model(s) (the EntitySubscription model).

You will notice a few things are still missing. One thing is that this row action displays whether the user is following the Account or not. Salesforce will not allow you to create more than one identical EntitySubscriptions. It will not break your page if the user clicks "Follow" on an Account he is already following, but it won't notify him either. AND the Unfollow button is a little trickier. It would be great if we could conditionally render the Follow button based on whether any rows exist in the EnititySubscription model. That would be a great idea to post in the community. It might get really positive responses from other users.

Let me know if you have any questions about this.
Emily