Category Archives: Requests

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="//"></script>
<script src="/Scripts/Feedback/SPJS-CollectFeedback.js"></script>
<script type="text/javascript">

		"feedbackAddedAlert":"Thank you for the feedback!",
Or use this code to insert a regular button
<input type="button" value="Send feedback" onclick="triggerFeedback();" />
<script src="//"></script>
<script src="/Scripts/Feedback/SPJS-CollectFeedback.js"></script>
<script type="text/javascript">

function triggerFeedback(){
		"feedbackAddedAlert":"Thank you for the feedback!",
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.


Remove click events and disable anchor tags in a SP2010 calendar view

I got a request from Larry Pfaff:

…Can all the links be disabled on a calendar view and allow navigation between months for sp 2010?

A bit back and forth between Larry and me produced this code:

<!-- refer jQuery -->
<script type="text/javascript">
$(".ms-acal-rootdiv").bind("click dblclick",function(){
            return false;
            $(".ms-acal-item [bricked!='1']").each(function(){    
                        $(this).attr("bricked","1").bind("click dblclick",function(){              
                                    return false;
            // Single day events
            $(".ms-acal-sdiv a").each(function(){
                        var text = $(this).text();
            // Events spanning multiple days
            $(".ms-acal-mdiv a").each(function(){
                        var text = $(this).text();

Put it in a HTML Form web part – or link it from a CEWP placed below the calendar view.

This code is tested in SP 2010 only.


Translate SharePoint form field label and description by a dropdown select

Change log
August 08. 2013
Moved the code for the file “TranslateFormFields.js” to due to errors in the preview.

I got this request from Mary Larson for a solution to translating a SharePoint 2010 form in 20+ languages by the selection of a desired language in a dropdown select.

I guess installing all these languages as language packs and using the MUI interface to translate the form is not an option.

I created this solution for translating the form label and description (description not supported in DispForm) – with cookie support for remembering the selected language.

Get the code for the file TranslateFormFields.js here.

You can either include this code in the HTML Form Web part or you can put it in a folder as a separate file and refer it using a script tag.

When the above code is referred, call the translation script like this from a HTML form Web part placed below the form web part:

<script type="text/javascript" src="/Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/Scripts/TranslateFormFields.js"></script>
<script type="text/javascript">

	The translation setup:
	dropdownLabel: "text" is the displayed text, "style" is the CSS style you want to apply to the label.
	dropdownDefaultVal: This is the initial value you want to display in the dropdown.
	lcArr: This is the array of languages as they should appear in the dropdown select.
	translations: This is an object literal in this format:	
		FieldInternalName_of_field : [
							"description":"This is the norwegian title"
							"description":"This is the swedish title"

						{ // Norwegian
							"description":"This is the norwegian title"
						{ // Swedish
							"description":"This is the swedish title"
						{ // Norwegian
							"description":"This is the norwegian status"
						{ // Swedish
							"description":"This is the swedish status"

This code is tested in a out of the box SharePoint 2010 only, but it most likely will work in out of the box forms in SP 2007 and 2013 as well.

Please let me know if you have trouble getting it to work, or you have any success stories.

If you like the solution, please click the beer mug in the top right margin of this page to buy me some beer!


Open PDF files in a maximized dialog

I got a request from Brett Anderson regarding a solution for opening PDF files in a maximized dialog window in SharePoint 2010. This code will most likely work in SharePoint 2013, but it has not been tested.

Please note that “Browser file handling” must be set to “Permissive” under “Web application general settings” in SharePoint Central Administration.

This is the code we ended up with after some back and forth:

<!-- Put this code below the list view web part -->
<script type="text/javascript" src="//"></script>
<script type="text/javascript">

function openPDFinDlg(href){
	var o;
	$("body").append("<div id='pdfTemp' style='min-height:600px;min-width:800px;height:100%;overflow:hidden'><object data='"+href+"' width='100%' height='100%' type='application/pdf' ></object></div>");
	o = {};
	o.html = $("#pdfTemp")[0];
	o.showMaximized = true;
	o.title = href.substring(href.lastIndexOf("/")+1);
	o.dialogReturnValueCallback = openPDFinDlgCallback;	

function openPDFinDlgCallback(){
	 // do something here when the dialog closes


SharePoint form: present fields side-by-side: Updated version

I have previously posted a solution for presenting form fields side-by-side.

This is an updated version derived from the DFFS project.

I have made this updated version by request from Steve Eberl because the older version proved incompatible with IE10. Hopefully this new version will be more compatible, but honestly: I have not tested it in IE10, as I have not installed it yet!

I have done some quick tests in SharePoint 2007 and SharePoint 2010. I guess it will work for SharePoint 2013 also, but this has not been confirmed. Please let me know if someone has tested it.

<script type="text/javascript" src="/test/English/Javascript/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/test/English/Lists/SideBySide/spjs-utility.js"></script>
<script type="text/javascript">

spjs_sideBySide = {
		var h, b;
			var cssArr = [];
			cssArr.push("<style type='text/css'>");
			$("body").append(cssArr.join("")); = true;
				$(fObj[o.fin]).before("<tr class='sbs_OuterTR' id='sbs_OuterTR_"+o.index+"'><td valign='top' colspan='2'><table class='sbs_OuterTable' style='width:100%' cellpadding='0' cellspacing='0'><tr class='sbs_InnerTR' id='sbs_InnerTR_"+o.index+"'></tr></table></td></tr>");
			h = $(fObj[o.fin]).css("display") === "none";
			b = [];
			b.push("<td FieldDispName='"+$(fObj[o.fin]).attr('FieldDispName')+"' FieldType='"+$(fObj[o.fin]).attr('FieldType')+"' class='sbs_Field' fin='"+o.fin+"' id='sbs_Field_"+o.fin+"' valign='top' style='white-space:nowrap;");			
			b.push("<table class='sbs_FieldTable' style='width:100%' id='sbs_FieldTable_"+o.fin+"' cellpadding='0' cellspacing='0'></table>");
					$("#sbs_FieldTable_"+o.fin).append("<tr class='sbs_FieldLabel' id='sbs_FieldLabel_"+o.fin+"'><td class='ms-formlabel'> </td></tr>");
				$("#sbs_FieldTable_"+o.fin).append("<tr class='sbs_FieldLabel' id='sbs_FieldLabel_"+o.fin+"'></tr>");
			fObj[o.fin] = $("#sbs_Field_"+o.fin)[0];
		if(_spPageContextInfo.webUIVersion === 15){
			}, "sp.js");
			var dlg = SP.UI.ModalDialog.get_childDialog();
			if(dlg != null) {				
				if(!dlg.$S_0 && dlg.get_$Z_0()){
					var xPos, yPos, win = SP.UI.Dialog.get_$1(), xScroll = SP.UI.Dialog.$24(win), yScroll = SP.UI.Dialog.$26(win);
					xPos = ((SP.UI.Dialog.$1d(win) - dlg.$2_0.offsetWidth) / 2) + xScroll; 
					if (xPos < xScroll + 10) {
						xPos = xScroll + 10;
					yPos = ((SP.UI.Dialog.$1c(win) - dlg.$2_0.offsetHeight) / 2) + yScroll;
					if (yPos < yScroll + 10) {
						yPos = yScroll + 10;
					dlg.$T_0 = xPos;
					dlg.$U_0 = yPos;
					dlg.$m_0(dlg.$T_0, dlg.$U_0);
					dlg.$ = Math.max(dlg.$6_0.offsetWidth - 64, 0) + 'px';

var fields = init_fields_v2();
	index: Use the same index for all fields in the same row.
	fin: FieldInternalName of the field.
	labelHidden: Hide form label.
	padHiddenLabel: If labelHidden = true, set this to true to fill the empty space left from the hidden formlabel.

var arr = [

// For SP 2010

Please let me know whether it is functioning as expected.


Dynamic Forms for SharePoint: Now with side-by-side

Change log
May 06. 2013
I have released v2.95 – you find it here
April 28. 2013
Bugfixes in v2.94:

  • Fixed a bug regarding comparing date and time columns where the trigger column is empty.

April 14. 2013
Bugfixes in v2.93:

  • Fixed bug in validating required rich text field when using non English letters.
  • Fixed bug where fields appearing in the “orphan fields tab” when using Side by Side.
  • Prevented the ID column from appearing in the “orphan fields tab”.
  • Fixed bug where people pickers lost their value in EditForm in Chrome (and possibly other non-IE browsers).

There are changes in both “DynamicFormsForSharePoint_v2.js” and “default.css” – ensure you update both.

March 29. 2013
Bugfixes in v2.91:

  • Fixed bug in side-by-side functionality regarding the “fields” not getting the correct fieldtype and fielddispname attributes.
  • Fixed bug where the field label was repeated multiple times when combining side-by-side with readonly, and then switching tab.

I have released version 2.90 of Dynamic Forms for SharePoint with these changes:

  • Added content type choice as possible trigger field.
  • Added side-by-sice capabilities.
  • Fixed a bug where the link to add tabs were missing for the first setup.
  • Changed the function that dynamically resizes the dialog. This new function is created by Sing Chan, and can be found here
  • Added a fix for some occurrences where the variable L_Menu_LCID was missing in a SP2013 setup.
  • Fixed a bug in SP.UI.RTE.js that occurs when hiding rich text columns in SP2010. The workaround is provided by John Chapman.

Refer these articles for background information and setup instructions:
Dynamic Forms for SharePoint: Production
Dynamic Forms for SharePoint – Now with Tabs
Dynamic Forms for SharePoint: Now with support for SharePoint 2013

How to use the Content type as trigger

In NewForm and DispForm the content type is not visible other than in the URL. You must use the trigger “URL Query string parameter”, and “This value” like this:


Please note that the default content type id not always shows up in the URL. If you click the “New Item” in the ribbon (in SP2010), it is included, but if you click the “Add new item” below the list view, it is not. You should therefore add rules for the “not default content type”.

How to find the ContentTypeId
Go to list settings, click the content type you want the id from, and then look at the URL. You will find it like this:


In EditForm, you can select the content type select ine the trigger fields and address it by its display name.

Details on the side-by-side functionality

I have added an option to place fields side-by-side in the tabs like this:

The configuration is setup like this:

The yellow input fields is used to specify a common index number for the fields that are to be presented side-by-side. The fields will be lined up with the topmost field in the selection.

The checkbox is used to hide the form label for the fields like this:

Please consider the side-by-side functionality BETA, and report any bugs back to me by adding a comment below.


Show field description in list view column header – updated version

I have previously posted this solution that lets you add the field description to the list view column header.

By request I have updated the solution to work in a web part page with multiple lists / libraries.

Put this code in a Content Editor Web Part at the bottom of your list view or web part page:
<script type="text/javascript" src=""></script>
<script type="text/javascript">
var is2010 = typeof(_fV4UI)!==’undefined’;

var wpID, tCtxId, tCtx, myTooltipObj, toFind, fieldDisplayName
wpID = $(this).attr(‘WebPartID’).toUpperCase();
tCtxId = g_ViewIdToViewCounterMap["{"+wpID+"}"];
tCtx = eval("(ctx"+tCtxId+")");
myTooltipObj = customGetList(tCtx.listName);
toFind = " th";
toFind = "";
fieldDisplayName = $(this).attr(‘DisplayName’);
fieldDisplayName = $(this).find("table:first").attr(‘DisplayName’);
fieldDisplayName = $(this).text();

function customGetList(listName){
var xmlWrap, result;
xmlWrap = [];
xmlWrap.push("<?xml version=’1.0′ encoding=’utf-8′?>");
xmlWrap.push("<soap:Envelope xmlns:xsi=’’ xmlns:xsd=’’ xmlns:soap=’’>");
xmlWrap.push(‘<GetList xmlns="">’);
xmlWrap.push(‘<listName>’ + listName + ‘</listName>’);
result = {};
url:L_Menu_BaseUrl + ‘/_vti_bin/lists.asmx’,
contentType:"text/xml; charset=utf-8",
$(‘Field’, data).each(function(i){
if(result[$(this).attr(‘DisplayName’)]===undefined || result[$(this).attr(‘DisplayName’)]===”){
result[$(this).attr(‘DisplayName’)] = ($(this).attr(‘Description’)===undefined)?”:$(this).attr(‘Description’);
return result;


If you like this solution, buy me a beer!


Approve multiple documents or list items in one operation with client side code

I got this request from Larry:

Good day A, Have a question. Is there an easy way to add to the SP 2010 ribbon an approve all button. I hate having to select each item and manually approve each one. I have found some script but they are deployed on central admin. I would like to a void that.


It’s not like i didn’t have anything to do, but he bought me a beer…

Here we go

This one uses the Client Object Model in SharePoint 2010 and is therefore usable in SharePoint 2010 only.

The code adds a custom button to the “Ribbon.Document” or “Ribbon.ListItem” that calls a script on the items selected using the in line checkbox.

Get the file “ApproveSelected.js” from here
Get jQuery from here

Put the files in a document library or in a folder created with SharePoint Designer. Ensure all users have read access to the location.

Insert a CEWP in the list view where you want this feature to be activated. Use the “Content Link” option in the “Edit web part” panel of the CEWP to link to the CEWP-code that you have put in a text file in the same location as the “ApproveSelected.js”.

Use this code:

<script type="text/javascript" src=""></script>
<script type="text/javascript" src="/test/Scripts/ApproveSelected/ApproveSelected.js"></script>
<script type="text/javascript">

var tabBtn = {
	"btnLabelApprove":"Approve selected",
	"btnLabelReject":"Reject selected",
	"groupLabel":"Approve or reject"
var workingOnItNotification = 'Processing items...';
var doneNotification = '{0} items processed';

Change the path to the file “ApproveSelected.js” to match your local copy. If you prefer to use a local copy of jQuery, change that path to.

You may also change the variables if you want another text in the button or the notification messages.

It should look like this in the list view



The button will disappear if the screen width is to narrow. The built in ribbon buttons will “shrink” to fit a narrow screen – this one will not.


This code uses a new “hack” to overcome the missing “list toolbar” when adding another webpart to the page. I’ll do a separate little article on that one.