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.
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.
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.
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.
<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>
<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>
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
Dear Alexander,
Works like a charm!
Thank you for your help!
You’re welcome – and thank you for the beer!
Alexander
boo hoo Alexander why does it not work for SP2007? Thats all I have 🙁
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
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.
I have updated the code to v1.1 – could you take a look?
Alexander
Works great. Thanks.
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.
Hi,
Try out v1.2 – read the instructions.
Let me know how it works out.
Alexander
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
Hi,
In line 79 – change like this:
to this:
Alexander
Hi Alexander,
Your solution is nice. it works as expected.
I have used v1.2 on my site. I added CEWP to llibrary Dispform.aspx to collect item url and item title. but script is copying url with two times “?ID=ID?ID=ID”
Ex:
http://SharePointSite/mysite/Piclibrary/Forms/DispForm.aspx?ID=5?ID=5
how can i remove second time ?ID=ID automatically. Can you help? is there a way to make change in script directly?
Thanks,
Hitesh
Hi,
This is fixed in v1.3 – see change log in the top of the page.
Alexander
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
Are you using a non-English language? – look at the yellow note in the top of the article.
Alexander
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
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
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
Thanks! – I’m glad it worked out.
Alexander
Hi Alex
Is it possible to hide the title/url/sitename fields from the form but still receive the url of the page the form was completed on?
Just to note – can do this via content types but seems the title field has to be present on form….any way round that?
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