Skuidify an Idea Theme?

  • 1
  • Question
  • Updated 4 years ago
I want to create a page that shows users all of the ideas submitted for a specific Idea Theme. 

The only thing I'm struggling with is how to give users a way to "upvote" or "downvote" an idea in the table using a row action. 

Essentially, the action would be creating a new "Vote" record, associated with the Idea row from where the action was clicked, with some predefined values (type=Up, createdby= User ID of Running User.) Here is the API documentation: http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_vote.htm

How can I do this?
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
  • hopeful

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I built an application that had a similar principle (though it was all on custom objects).  Row Action tied to the action framework are your friend. 

Build 2 row actions that do the following. 
1. Create new Row in the Vote model
2. Prepopulate that new rows with Idea Id (context from the table of ideas), User ID and UP or Down. 
3. Save the row

This will take care of the voting for you.  But you also want to prevent users from voting twice.  Do that by removing rows from the idea table if users have voted in them.  (Maybe add them to a table underneath of "cast votes").  I can't think of how to make the vote icons only appear conditionally - as we can't do conditional rendering on child records. 

Hope that sketch gives you some direction to work with. 
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
How do I pre-populate with the User ID? It looks like I can just enter text in the action area, but no parameters. Same for pre-populating with context id from the idea row. I don't have the option. 

Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You can enter merge data in those via mustache.
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
Thanks, Pat!

How do I tell it {{the id of the idea record on this row, which is from a model called "Ideas"}} ? Or, {{the id of the user running the page}}
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
{{Id}} is for current row. Whether it's the model for Ideas, or Opportunities, or whichever. It's in context so you wouldn't need to specify the model or row.

{{$User.userId}} for the user id.

This page has all the goodies. http://help.skuidify.com/m/11720/l/187263-global-merge-variables-functions
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
Wooo! Thanks again, Pat! Bookmarking that. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Yup. Very handy. Use it all over the place.
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
Ay carumba. Anyone know how to get at the vote object? No matter how I try to do it, I get this error: 

An error occurred while attempting to perform the following SOQL query: SELECT ParentId,Type,Id FROM Vote LIMIT 21 Error:Implementation restriction: When querying the Vote object, you must filter using the following syntax: ParentId = [single ID], Parent.Type = [single Type], Id = [single ID], or Id IN [list of ID's].
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You'll need to add a condition for one of those. ParentId = [single ID], Parent.Type = [single Type], Id = [single ID], or Id IN [list of ID's]
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
I am still running into new errors. Now I get "Required Fields are Missing: Parent, Vote Value." 

I am pushing the parent ID, so I am not sure what Parent refers to. There is no Vote Value field accessible in field selection, or listed in Salesforce API docs. 

:(