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…

Advertisement

12 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

Leave a Reply to kajal Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s