Collect feedback from pages or list items

Change log
February 07. 2015
Updated to v1.3:

  • Fixed a bug introduced in v1.1. When triggering this from a list item, you ended up with two entries for “itemID” in the URL.

February 14. 2014
Updated to v1.2:

  • Added option to store the site title in an additional field in the list. To activate this, add a field with FieldInternalName “SiteTitle” to the list.

January 28. 2014
Updated to v1.1:

  • Include site title in the Title field in the feedback if it is collected from a page and not a list item.
  • Changed from locationl.pathname to the full location.href in the URL for collected feedback.

I got this request:

Dear Alexander,
I’ve been cruising your blog for a week or so and I have to say – THANKS!
The solutions you posted are wonderful and very helpful!

I have a special request that might be useful for many users and I’ll defently buy you a nice cold beer for it !

I need a way to send a feedback from any list item and page in SharePoint. The way I see it is some clickable button in a CEWP inserted in a page and some custom button in the ribbon of a list item.

I’d been asked to allow the users to answer some questions (2-4 pre added) and the ability to add some text of their own.

If there’s a way to have your assistance in that matter I’ll adores you forever and send you a cold beer to chill.

Thanks in advance,
Eron F.

The solution

This solution is for SP 2010 or 2013 only and it will NOT work for SP 2007.

This solution will add a banner button or a regular button (details below) that lets your users add feedback to a custom list in the site collection. The solution will fill the “Title” column with the list item title if it is a list item (DispForm or EditForm) and the URL from where the feedback was added. You can add this code to any page in the site collection using a CEWP.

How to set it up

Start with adding a custom list to the site collection. This list must Include the standard “Title” field (already present), a single line of text column called “URL”, and another single line of text column named “SiteTitle”. These columns are used to log where the feedback was added from. You must add additional columns to this list to collect the actual feedback – like a multi line text field. Which columns you want to add is up to you. The relative URL to this list is used in the argument object described below. This custom list does not require any code added to it.

Not using English language?
You must change the display name for the localized Title field to the English “Title” in the list you want to store the feedback in. This because the script addresses the field by display name.

Download the latest version of SPJS-CollectFeedback from here, and put it in a document library where all users have READ ACCESS.

When this list is set up and the file “SPJS-CollectFeedback.js” is downloaded, you can add the code from the code block below to any page in the site collection using a HTML Form Web Part or CEWP. You might want to change the jQuery reference to a local copy, and you must change the reference to “SPJS-CollectFeedback.js” to point to your local copy.

Use this code to insert a ribbon button
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="/Scripts/Feedback/SPJS-CollectFeedback.js"></script>
<script type="text/javascript">

$(document).ready(function(){
	spjs.collectFeedback.initRibbonBtn({
		"feedbackListNewFormURL":"/CommentBox/Lists/Feedback/NewForm.aspx",
		"feedbackAddedAlert":"Thank you for the feedback!",
		"feedbackNotAddedAlert":"",
		"ribbonBtnText":"Send<br>feedback",
		"ribbonBtnImg":"/_layouts/images/ltann.gif"		
	});
});
</script>
Or use this code to insert a regular button
<input type="button" value="Send feedback" onclick="triggerFeedback();" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="/Scripts/Feedback/SPJS-CollectFeedback.js"></script>
<script type="text/javascript">

function triggerFeedback(){
	spjs.collectFeedback.init({
		"feedbackListNewFormURL":"/CommentBox/Lists/Feedback/NewForm.aspx",
		"feedbackAddedAlert":"Thank you for the feedback!",
		"feedbackNotAddedAlert":""
	});
}
</script>
The various arguments

feedbackListNewFormURL: The relative URL of the list to store the feedback in.
feedbackAddedAlert: If this is not an empty string you will get an alert after adding the feedback.
feedbackNotAddedAlert: If this is not an empty string you will get an alert if you cancel adding the feedback.
ribbonBtnText: The label of the ribbon button.
ribbonBtnImg: The image of the ribbon button (32×32 px).

Post a comment below if you like the solution or you have any questions.

Alexander

22 thoughts on “Collect feedback from pages or list items”

    1. Hi,
      This solution utilizes the built in dialog boxes in SP 2010 and SP 2013. To make it work i SP 2007 I would have to use another method. I’m currently very busy and cannot create this solution, but I may come back later if there is demand (and beer).

      Alexander

  1. Alex, thanks for this solution. Very helpful. Couple of questions.
    1) Is there a way to populate the full path to the page/list that the feedback is coming from? Even better I’d love it if the path was a hyperlink so a person could just click on it from the feedback list to get to the place the feedback is coming from.
    2) All my titles come out as […] Is there a way to make the title of the feedback item something else, such as the name of the page or list the feedback was from?

    Thanks.

  2. Hi Alexander,

    It works great! Thank you!

    Though I have a small question, I want to place the feedback list in some root site. Is it possible to add a column to the list that add the site Title? (site name)

    thanks!
    Sam.

  3. Alex,

    I’m having an issue when the dialog window pops up, there is a horizontal scroll bar. Is there a way in the script to set the window size? I looked and I couldn’t tell if that was being set or it’s just a system default.

    Brendan

    1. Hi,
      In line 79 – change like this:

      OpenPopUpPage(url,function(a){
      if(a === 1){
      	if(spjs.collectFeedback.args.feedbackAddedAlert !== ""){
      		alert(spjs.collectFeedback.args.feedbackAddedAlert);
      	}
      }else{
      	if(spjs.collectFeedback.args.feedbackNotAddedAlert !== ""){
      		alert(spjs.collectFeedback.args.feedbackNotAddedAlert);
      	}
      }
      });
      

      to this:

      OpenPopUpPage(url,function(a){
      if(a === 1){
      	if(spjs.collectFeedback.args.feedbackAddedAlert !== ""){
      		alert(spjs.collectFeedback.args.feedbackAddedAlert);
      	}
      }else{
      	if(spjs.collectFeedback.args.feedbackNotAddedAlert !== ""){
      		alert(spjs.collectFeedback.args.feedbackNotAddedAlert);
      	}
      }
      },800,600);
      

      Alexander

  4. Hi Alexander

    Your code seems exactly what I’m after but it doesn’t seem to populate any of the list items. All I get is the blank form opening which I can then save. I’m using SharePoint 2013 as part of Office 365 if that would make any difference?
    Its probably something really simple that i’m doing wrong.

    Any ideas,

    Thanks

    Paul

  5. Hi Alexander

    No we’re using English language on our tenant as we’re in the UK. I’ve had a look and the field names look correct. I’ve tried a few different versions on the SPJS-CollectFeedback in case that made a difference, but same result. All I get is the default new item form opening with no data populated.

    Any ideas?

    Thanks

    Paul

    1. This script using the “title” attribute on the fields. If you have set the fields as required, the “title” attribute will not be “Title”, and “URL”, but “Title Required Field” and “URL Required Field” – this change was made to SharePoint after this solution was posted, most likely for compatibility with screen reader software.

      Try removing the required property and see if this helps.

      Alexander

  6. Hi Alexander

    You were absolutely correct. The title field was still set to require. I changed that option and it worked first time.
    Much appreciated, and a beer donation will be coming your way.

    Thanks

    Paul

  7. Hi,
    I’m not sure I understand what you mean. I’t been a while since I looked at his code, but from what I recall the Title, URL and SiteTitle is supposed to be hidden by the code – look at the bottom of the JS file where all “tr’s” are set to “hide()”.

    Alexander

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.