SPFx – Quick Poll

Introduction

This component is developed as a SharePoint Framework web-part to create poll, capture response from the user’s and to display the results in a graphical view. This quick poll is very easy to maintain and quick to set up. The list ‘QuickPoll‘ which captures all the question and responses will be created automatically.

Features

  • Easy to setup with most of the configurations are optional.
  • Flexible to use without any critical configuration.
  • More than one poll questions can be added.
  • Schedule the poll questions in advance using the date parameters.
  • Option to choose the poll that has to be visible to the end users.
  • Poll response can be viewed via graphical representation as charts.

Properties

  • Display poll based on date – This property will check for the ‘Start Date’ and ‘End Date’ on the poll questions to display the correct poll question to the end user. The ‘Start Date’ and ‘End Date’ on the poll question will be enabled only when this property is turned on.
  • Poll Questions – Manage the collection of poll questions and choices.
    • Question Title – Title of the question.
    • Choices – Choices separated by comma.
    • Multi Selection – Whether the users are allowed to choose one or multiple.
    • Start Date – Date when the end user can start seeing the poll question.
    • End Date – Last day of the poll question visible to the end user.
  • Success Message – Message to be displayed to the user after successful submission. It is optional, if not provided the default message ‘Thank you for your submission‘ will be displayed.
  • Response Message – Message to be displayed to the user with the user response, once the user has submitted. It is optional, if not provided the default message ‘You Voted For: User Response‘ will be displayed below the chart.
  • Submit button text – Text to be displayed on the submit button. It is optional, if not provided the default text ‘Submit Vote‘ will be displayed.
  • Preferred Chart Type – Chart type to display the overall response for the question.

Note:

  • Poll questions with the same ‘Start Date’ and ‘End Date’ will follow the sort order to display the latest question to the end user.
  • Once the user started to response to the poll, do not delete the question from the question collection. All the questions are mapped based on the ID auto generated. It cannot be recovered once deleted.
  • Make sure the Multi Choice option is chosen wisely, do not change once the user started to response to the poll.

Preview

Source Code

The above web-part is shared with the community and is of free to use. Please click the below link to download the code and have fun.

https://github.com/pnp/sp-dev-fx-webparts/tree/master/samples/react-quick-poll

Happy Coding…

18 thoughts on “SPFx – Quick Poll

    • Hi Denisse, the solution reference on the blog post points to the latest version which is only for SharePoint online (v1.11.0). But you can create a solution using 1.4.1 for SP 2016 and then you can replicate the code. It should work. Let me know if you encounter any issues.

      Like

  1. Hi Sudharsan,

    I have tried this webpart in classic page. It is not working. It is working in modern site page only. Could you please tell me how to integrate this in classic page.

    Thanks

    Like

  2. Hi Sudharsan, Thank you for this quick poll, it works great !! (Using in O365)
    just an update/fix, I have to update below code in getAllUsersResponse Method.
    From:
    currentPollResponse: usersResponse[0].Response ? usersResponse[0].Response : usersResponse[0].MultiResponse.join(‘,’)
    To:
    currentPollResponse: filRes[0].Response ? filRes[0].Response : filRes[0].MultiResponse.join(‘,’)

    Else, it gives always the first person response in “You voted for: ”

    Once again thanks!

    Like

  3. Hello,

    We started using your Quick Poll app and have a question. It seems the version I have looks a bit different than your examples here. Here I see the question presented nicely in Bold, separating it from the selections below. We also see here that the ‘Submit’ button is centered, and again offers clean separation from the quesions above. In our instance on SP Online, the question is not standing out and the button is left-justified causing the selections to almost run into the button. Any way to get the previous version that looks better, or can we hope for a new version that addresses these issues? Perhaps some simple formatting built into the app options?

    Thanks, Mike.

    Like

  4. Hello,

    When I implemented the web part as the site owner, it is working perfectly fine, but when some site visitor tries to use it, they are able to select the option, there even comes a message that says ‘Thank you for your submission’, but the result graph is not displayed then for the site visitor, and the poll gets refreshed when the site is refreshed for the same visitor.

    Like

Leave a reply to Sudharsan K... Cancel reply