You need to sign in to do that
Don't have an account?
Douglas Hauck
Example of using PollCapabilityInput to vote?
Hi, all -
I'm trying to set up a helper method to generate a ConnectApi.PollCapabilityInput class. (This is part of a larger helper class to generate FeedItemInputs.) According to the documentation, this class has two properties:
I would really like to see a complete example for this Capability, but I can't seem to find one, here or anywhere else. Can someone point me toward such an animal? If not, does anyone at least know how to use this class to vote on an existing poll?
Thanks,
Doug
I'm trying to set up a helper method to generate a ConnectApi.PollCapabilityInput class. (This is part of a larger helper class to generate FeedItemInputs.) According to the documentation, this class has two properties:
- choices: List<String>
- The choices used to create a new poll. You must specify 2–10 poll choices for each poll.
- Required for creating a poll.
- myChoiceId: String
- ID of an existing choice on the feed poll. Used to vote on an existing poll.
- Required for voting on a poll.
I would really like to see a complete example for this Capability, but I can't seem to find one, here or anywhere else. Can someone point me toward such an animal? If not, does anyone at least know how to use this class to vote on an existing poll?
Thanks,
Doug
Please let me know how you used ConnectApi.PollCapabilityInput to create a poll. I'm new to Salesforce and an example code would be of great help.
Thanks in advance,
Arjun.
So first, I recommend you read the paragraph under ConnectApi.FeedElementCapabilityInput in the Apex Developers Guide (http://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_input_feed_element_capability.htm).
Basically, you don't create a "poll"; you create a normal post (a ConnectApi.FeedItemInput or FeedElementInput object) and set its capabilities property to a new ConnectApi.FeedElementCapabilitiesInput object. Now you can add any capabilites you want to that post, including polling, just by adding instances of the associated CapabilityInput classes (e.g. PollCapabilityInput) to the FeedElementCapabilitiesInput object you created.
The project I was working on when I asked this question got cancelled, so I never did find out how to use it to respond to a poll. But I have posted some code below that should allow you to at least create a poll. I will warn you that it's never been tested (because cancelled) but I'm reasonably confident it will work, and I've added some comments to help you expand on it. Hope it helps!!
Best,
Doug
Thanks a lot.
-Arjun.