Category Archives: Info

Status update

Hi all,
I have been more or less absent the past few weeks, and just wanted to let you know the status.

I have published many solutions over the past years, and I get a lot of questions related to setup problems, feature requests and requests regarding updating older solutions to support new browser versions or new jQuery releases.

I have always tried to answer all requests and questions, but must draw the white flag and say that I no longer can find time to answer them all – I simply cannot spend every night in front of my computer. I have a full time job working with SharePoint, and I feel I have overdosed on SharePoint a bit lately.

I have to prioritize a bit differently, and spending time with my wife and kids outrank blogging…

I will still be answering comments and try my best to maintain the solutions I have already published, but it will be less activity regarding new solutions for a while.

Stay tuned, and it will come some new stuff – just not so often as it used to.


How to troubleshoot when the scripts does not work

In most cases where users have trouble getting my solutions to work, the problem is the script references. I will give a few examples here on how to troubleshoot these cases.

To copy the script from sourcecode provided in the article, hover over the script and click “view source”. Highlight, copy and paste in notepad. Save with the correct file extension like this:

  • Select “Save as” from the file menu and be sure to use the “.js” extention in the file name. Below the file name, you find a drop down where you can set the file type.
  • Select “All files”. If you don not do this the file will be saved as “fielname.js.txt”.

To check that the scripts are referred correctly, insert an alert in the CEWP like this:

<script type="text/javascript" src="/test/English/Javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
  // Check that jQuery is loaded:

  // Check that a specific function is loaded:

Both these alerts should give a dialog box with the text “function”. If you get “undefined”, the script reference are wrong.

Another thing:
In most cases the CEWP must be placed below the list for or list view for the code to work.


How to use these scripts in a customized form

03.08.2010 Updated the article with another example on how to build the fields-object in a customized form.

This article describes how to use most of the solutions found in this blog with a customized form. The scripts which this article addresses, is the ones involving the function “init_fields()_v2”.

This was originally an answer to a comment in one of the articles.

I get this question a lot:
How can i use these scripts in a customized form?

The answer is simple, but i will explain it so that you understand why it’s not working.

This script relays in the function init_fields() to identify and “objectify” the form by it’s <TR> tags (table rows). What the function does is to find all the FieldInternalNames in the code by this “information-tag”:

&lt;!-- FieldName=&quot;This is the DisplayName&quot;

It then make an object which, when called with the FieldInternalName of a field, returns an object containing that table row (both formlabel and formtable).

When initiated like this:

fields = init_fields_v2();

You address a <TR> like this:


Where “FieldInternalName” is the FieldInternalName of your field. Read here how to identify the FieldInternalName.

This is the original function for use in standard SharePoint forms:

function init_fields_v2(){
	var res = {};
	var myMatch = $(this).html().match(/FieldName=&quot;(.+)&quot;s+FieldInternalName=&quot;(.+)&quot;s+FieldType=&quot;(.+)&quot;s+/);	
			// Display name
			var disp = myMatch[1];
			// FieldInternalName
			var fin = myMatch[2];
			// FieldType
			var type = myMatch[3];
			// Build object
			res[fin] = this.parentNode;
			res[fin].FieldDispName = disp;
			res[fin].FieldType = type;
	return res;

Customized form

When you modify the list form in SharePoint Designer, you loose the FieldInternalName and therefore the function init_fields_v2() does not return anything.

To address the fields on a custom form you have to find another way of addressing these fields and to “objectify” them in the same way as the script init_fields_v2(). Basically you could insert some kind of “identifier-attribute” on the <TR> tags, or you can go with the displayName – only remember that if you change the displayName – you have to update your script…

To use the a custom made ID attribute, replace the init_fields_v2() function with this one:

function init_fields_v2(){
  var res = {};
  	var thisID = $(this).attr('id');
	  res[thisID] = $(this).parents('tr:first');
  return res;

This approach requires that you add a unique ID attribute to the <TD> holding the formlabel. Here is an example of code from a customized form:

&lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;&gt;
		&lt;td width=&quot;190px&quot; valign=&quot;top&quot; class=&quot;ms-formlabel&quot; id=&quot;TitleColumnCustomID&quot;&gt;
			&lt;H3 class=&quot;ms-standardheader&quot;&gt;
				&lt;nobr&gt;Title&lt;span class=&quot;ms-formvalidation&quot;&gt; *&lt;/span&gt;
		&lt;td width=&quot;400px&quot; valign=&quot;top&quot; class=&quot;ms-formbody&quot;&gt;
			&lt;SharePoint:FormField runat=&quot;server&quot; id=&quot;ff1{$Pos}&quot; ControlMode=&quot;New&quot; FieldName=&quot;Title&quot; __designer:bind=&quot;{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}&quot;/&gt;
			&lt;SharePoint:FieldDescription runat=&quot;server&quot; id=&quot;ff1description{$Pos}&quot; FieldName=&quot;Title&quot; ControlMode=&quot;New&quot;/&gt;
		&lt;td width=&quot;190px&quot; valign=&quot;top&quot; class=&quot;ms-formlabel&quot; id=&quot;ChoiceColumnCustomID&quot;&gt;
			&lt;H3 class=&quot;ms-standardheader&quot;&gt;
		&lt;td width=&quot;400px&quot; valign=&quot;top&quot; class=&quot;ms-formbody&quot;&gt;
			&lt;SharePoint:FormField runat=&quot;server&quot; id=&quot;ff2{$Pos}&quot; ControlMode=&quot;New&quot; FieldName=&quot;MyChoiceColumn&quot; __designer:bind=&quot;{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@MyChoiceColumn')}&quot;/&gt;
			&lt;SharePoint:FieldDescription runat=&quot;server&quot; id=&quot;ff2description{$Pos}&quot; FieldName=&quot;MyChoiceColumn&quot; ControlMode=&quot;New&quot;/&gt;

Note the id attributes “TitleColumnCustomID” and “ChoiceColumnCustomID” in line 03 and 15.

To “get” the Title field you address it like this:

fields = init_fields_v2();
var myTitleField = $(fields['TitleColumnCustomID']);

Ask if anything is unclear.



Post requests and questions in this post, but be patient awaiting reply or solution examples. This is a “one man blog” and i have limited time to answer questions. There will be less activity during the summer months, but i will keep posting new solutions, only on a slightly smaller scale.

I’m open to requests!
I get many ideas on things to write about from my readers, feel free to make requests on things you would like to learn more about.

I will, from the best of my knowledge (and time), answer your questions.

Post requests as comments to this post.


Use the rating on the request to vote them up, thus “forcing” me to answer them…

The comments are split into pages with 25 top level comments per page, and the last page displayed by default. Use the links at the bottom of the page to read older comments.