Category Archives: Javascript

Convert text fields to cascading dropdowns – unlimited number of levels

You find updated documentation here

Change log
August 21, 2015
Changes in v3.524

  • Fixed a bug when using single quote in the items used in the dropdown menu.

July 13, 2015
Changes in v3.523

  • Fixed issue with :multi and hide empty dropdowns not hiding the correct elements.
  • Fixed issue with :multi and autofill single option not properly selecting the items.

May 06, 2015
Changes in v3.520

  • Fixed a bug that prevented the solution from working if you did not have spjs-utility.js loaded in the page where you used the cascading dropdowns.
  • Made some changes to the debug output. The debug is now show directly in the page so there is no need to open the developer console.

April 15, 2015
Changes in v3.510

January 19, 2015
Changes in v3.30

  • Added support for autofilling values when using “Autofill subsequent dropdowns when they contain only one valid option.” in DFFS.
  • Changed the jQuery variable from $ to spjs.$ to fix a bug with SharePoints internal file “assetpicker.js” as this one kills jQuery.

September 4. 2014
Changes in v3.27
Fixed an issue where DFFS triggers on subsequent dropdowns would not trigger when the “Autofill subsequent dropdowns when they contain only one valid option” is checked (and the options are autofilled).

September 3. 2014
Changes in v3.26
Added “lookupListBaseUrl” as option in the argument to the function. This is used to lookup from a list that is not located in the same site (but in the same site collection). If you are using DFFS v4 you must update to this version.

June 10. 2014
Changes in v3.25
Skips the loading of the script if it is loaded in DispForm. This will prevent some errors when using this solution with DFFS and you are cloning settings from NewForm or EditForm.

June 7. 2014
Changes in v3.24
Added autofill of subsequent dropdowns if the field has a default value.

March 1. 2014
Changes in v3.22
Added new switches: “autoselectSingleOption” and “clearInvalidSelection”. See description below.

February 20. 2014
Changes in v3.21
Added autoselect if only one option is found.

August 29. 2013
I had forgotten a console.log in v3.1, Please download it again.
August 28. 2013
Changes in v3.1
Fixed a bug that prevents getting more then 30 items for each dropdown.

This solution lets you convert multiple single line textfields to cascading dropdowns populated by a query into another list that holds the data.

I’m reusing these two images from a previous article in this series to demonstrate the source list configuration and the target list appearance after the solution is initiated:

From v3.510 you can use multiselect in all the dropdowns.


I have previously posted two solutions in this series:
Cascading dropdowns
Cascading dropdowns in SharePoint text fields – populated by lookup in another list (version 2)

This is the third revision done mainly for compatibility with the Dynamic Forms for SharePoint solution, but it can also be used as a standalone solution. The earlier solutions had a 5-level limit, but this one in unlimited.

Used with the Dynamic Forms for SharePoint solution

Refer this solution in the CEWP where you set up the DFFS solution like this:

<link type="text/css" href="/Scripts/DFFS/default.css" rel="stylesheet">
<script type="text/javascript" src="/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/Scripts/spjs-utility/spjs-utility.js"></script>
<script type="text/javascript" src="/Scripts/CascadingDropdowns/SPJS-Casc_min.js"></script>
<script type="text/javascript" src="/Scripts/DFFS/dffs.js"></script>

You will now find the configuration for the solution as a separate tab in the DFFS GUI:

Please note that you will not find this tab when configuring DispForm, and that this will require version 3.1 or later of the DFFS solution.
Used as a standalone solution

To use this as a standalone solution, you must do the configuration in the CEWP code like this:

<script type="text/javascript" src="/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/Scripts/CascadingDropdowns/CascadingDropdowns.js"></script>
<script type="text/javascript">
Please note that the CEWP must be placed below the list view web part.
Parameters explained

lookupList: List name or GUID of the list that holds the values to populate the dropdowns.
lookupListBaseUrl: Base URL of the site where the list is located. This is NOT the URL of the list itself.
lookupListFields: The FieldInternalNames of the fields in the above list.
thisListFields: The FieldInternalNames of the fields to convert to dropdowns.
dropDownDefaultvalue: The value to display in the dropdown select when no items has been selected.
hideEmptyDropdowns: Determines whether or not to hide dropdowns with no available options.
autoselectSingleOption: If the next dropdown contains only one option it will be automatically selected.
clearInvalidSelection: If you open a list item in EditForm and the original selection no longer is a valid selection, you can decide whether to clear it or keep it.
debug: Used to troubleshoot the setup. You must have the developer console activated to read the debug information. While this is “true”, the single line of text field will show below the dropdown select.

The length of the arrays “lookupListFields” and “thisListFields” must be the same.

Using multi select

Read this article to learn how to use the multi select option for the fields.

Download code

Get the code for the file “CascadingDropdowns.js” here.

Please support the development of this solution by hitting the “beer button” in the top right corner of this page to buy me a few beers.

Have fun,

vLookup for SharePoint 2013 v1.5

Change log
September 3, 2014
Changes in v1.730:
Minor update for compatibility with DFFS v4 “direct to backend script”.

June 27, 2014
Changes in v1.723:
Added check for a function named “vlookupChildViewOrEditCallback” to detect open or edit of a child (in dialog only). Add a function with this name, and it will be called when the dialog closes.

April 29, 2014
Changes in v1.721:

  • Fixed a bug from the previous version when using [URL:Key] in the CAML: NOT supplying the URL parameter generated an error.
  • Changed how the debug also alerts the values set in NewForm of the child item when using ?vLookupDebug=1 in the url

April 27, 2014
Changes in v1.720:

  • Fixed first column width if header row is hidden.
  • png icons in SP2013 and fallback to white icon for file types not recognized.
  • Added icons to show the view state of the groups (when using grouping).
  • Added option to use a URL querystring variable in the CAML. Hover over the help icon for the “Build Query” or the “Write your own CAML-query” to learn how to use it.

April 21, 2014
Changes in v1.710:
If you leave all display names in the viewFields section empty, the header row will be hidden.

April 13, 2014
Changes in v1.700:

Please note that there are a number of changes in this version and there will most likely be a few new bugs. You should test it before adding it to a production environment. Let me know if you find a bug, and I’ll fix it as soon as I can manage.
  • Fixed a compatibility issue with “fixQuirkyLookup” in the function “init_vLookupFields”.
  • Added option for selecting whether or not to open “new child” in a dialog.
  • Added “Show all option” when using “Rowlimit”.
  • Added support for grouping the items.
  • When using “Attachments” as viewField you will now get the paperclip in stead of “Yes” or “No” to indicate that an item has attachments.
Please note that you must index the columns you are querying to prevent errors when you reach a total of 5000 items in the list.

April 13. 2014
Changes in v1.651:
Fixed an issue with IE 11 for SP 2013: L_Menu_BaseUrl is undefined.

February 2. 2014
Changes in v1.65:

  • Changed <View Scope=’Recursive’> to <View Scope=’RecursiveAll’> to fix a bug with discussions (that are in fact folders).
  • Added option to refresh all vLookup columns when one has changed.
  • Added option to open links in the same window, and not in a new dialog.
  • Minified the code.

January 04. 2014
Changes in v1.644:

  • Added L_Menu_BaseUrl and L_Menu_LCID to the script for IE 11 compatibility in SP 2013.
  • Wrapped the table cell values in a div for better handling of “ViewField Special configurations CSS”.
  • The “ViewField Special configurations CSS” will also be applied to empty cells.
  • Fixed missing refresh in list view when a vLookup item is added or edited.

December 06. 2013
Changes in v1.640:

  • A new Action: “Comma separated list” is added. See instructions on the help icon for the “Action” field.
  • Custom style now works for all column types and not only text and note columns.
  • Date format can now be specified in the “In URL” section. See the help icon for details.
  • A few small bugfixes.

November 12. 2013
Changes in v1.631:
Child table max-height: changed overflow:scroll > overflow:auto to hide the scrollbar if it is not needed.

November 3. 2013
Changes in v1.63:

  • Added option to pass an URL parameter to the child list NewForm when adding children. Hover over the help icon for instructions.
  • Added option to set the max-height on the child table to have vertical scrollbars.
  • Changed how the page id is calculated when storing and retrieving the configuration. In some cases it came out wrong.

October 11. 2013
Changes in v1.62:
Added the number formatting support for “Action” sum, average and count.

October 11. 2013
Changes in v1.6:
Updated the number formatting support and added separate setting for “thousandsSeparator”. You can now use one or more of the following settings: “decimals”:2,”thousandsSeparator”:”.”,”decimalSeparator”:”,”}

October 06. 2013
Changes in v1.59:

  • Fixed set multichoice column from URL.
  • Added automatic refresh of the vLookup table when editing a child.

September 16. 2013
Changes in v1.56: Fixed a bug regarding showing documents located in sub folders in a document library.

September 10. 2013
Changes in v1.55:

  • Fixed a bug regarding multi choice people pickers.
  • Changed the available “events” you can use.

Interaction / events (put code in the CEWP)

// If defined, this function is called when clicking on "add new child". This function must return true to allow for children, or false to disallow.
function vlookupAddChildPreCheck(fin){
		// check something and return false if conditions are not met
	return true;

// If defined, this function is called for each of the fields set in the child from the "In URL" setting.
function vLookupPresetFromUrlDone(fin){
		// do something

// If defined, this function is called when a vLookup column is rendered complete.
function vLookupIsLoadedCallback(fin){
		// do something

// If defined, this function is called when a child is added and you close the dialog with "OK".
function vlookupChildAddedCallback(){
	// Do something

// If defined, this function is called when you click "add new child", but close the dialog without saving.
function vlookupChildNotAddedCallback(){
	// Do something

August 28. 2013
Changes in v1.53:

  • Fixed bug in multiselect viewfields (checkboxes, multilookup and multiuser)
  • Added rowlimit setting for the query.
  • Changed some ids and variable names in the code.

This solution lets you create relationships between two or more lists based on for example a lookup column connection. You can list all children in the parent element (the children has a lookup column targeting the parent). This is not possible out of the box in SharePoint.

You can also have any kind of dynamic query based on values in the current form. You can for example pull in information from a list based on a selection in a choice column. Please note that this last example will not pull in this information on the fly when changing the selection, but when the form is loaded in DispForm, EditForm or in a list view.

This solution also lets you create new children from the parent (both DispForm, EditForm and in list views), and lets you auto-populate the “connection” to the parent element to ensure a connection.

Image from the GUI
I have previously posted two articles in this series:
vLookup for SharePoint 2010
vLookup now supports SharePoint 2013

This one is done mainly for compatibility with the Dynamic Forms for SharePoint solution, but I have redone the code and also fixes a few bugs and adds some new features:

  • The creation of the configuration list is now triggered when you first enter the setup. This is done to prevent some rare bugs where the list is not detected onload, thus asking to create it despite it already exists.
  • The heading for number columns are now aligned right (as the values)
  • Fixed bug where exiting the setup did not load the form with its item-ID.
  • Added custom css for the viewFields. Hover over the help icon to the right of the “ViewFields” section for details.
  • Added option to enter a license code to remove the PayPal-logo in the top of the GUI
Used with the Dynamic Forms for SharePoint solution

Refer this solution in the CEWP where you set up the DFFS solution (DispForm and EditForm) like this:

<link type="text/css" href="/Scripts/DFFS/default.css" rel="stylesheet">
<script type="text/javascript" src="/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/Scripts/spjs-utility/spjs-utility.js"></script>
<script type="text/javascript" src="/Scripts/vLookup/vLookup.js"></script>
<script type="text/javascript" src="/Scripts/DFFS/dffs.js"></script>
Used as a standalone solution in forms or list views

To use this as a standalone solution, you must do the configuration in the CEWP code like this:

<script type="text/javascript" src="/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/Scripts/spjs-utility/spjs-utility.js"></script>
<script type="text/javascript" src="/Scripts/vLookup/vLookup.js"></script>
First setup

Please note that the setup must be MANUALLY triggered the first time. Set up the scripts, create the vLookup column and then – in DispForm – add this to the URL to create the list:
/Lists/mylist/DispForm.aspx?ID=[an existing ID in your list]&vLookupSetup=1

Refer the previous articles in this series for further details on the setup process.

Download code

Get the code for the file “vLookup.js” here.

How to remove the PayPal-logo / Unlicensed version from the GUI?

In this version I have added support for providing a license code for removing the PayPal-logo and displaying a “Registered to” text in stead. To obtain a license code, go to this page, scroll down to “Dynamic Forms for SharePoint / vLookup for SP201X” and follow the instructions.

As this is JavaScript, there is of course no problem to bypass this license code and manually remove the logo, but please remember that I put in a lot of hours developing these solutions, and I appreciate a few beers now and then.

Please post any bugs or comments below.

spjs-utility.js v1.17

Change log
January 29. 2014
Added option to clear a people picker in SP 2013 using setFieldValue – specifying an empty string as new value.

November 24. 2013
Added option to pass scope to the function “spjs_QueryItems”. Use “scope”:”Recursive” to search all items without folders.

October 30. 2013
Fixed bug in init_fields_v2() regarding converting HTML formatted text in a calculated column to proper HTML.
getUserInfo_v2: customProp

October 23. 2013
Radio: setFieldValue will clear choices first. This mean you can set a radio choice field to “null” by passing an invalid value – like a blank string.
Calculated html converted in init_fields_v2()

September 13. 2013
In v1.173:

  • Added option to set a single choice Lookup column rendered as a <select> by ID.
  • This affects lookup columns with <20 items in IE, and all lookup columns in other browsers.
  • Changed the method of setting lookup colums to ensure they first try to match by TEXT and them by ID.

August 21. 2013
I had a mixup in the files and uploaded v1.17 in stead of v1.171. You will have to download v1.171 again. Sorry for the inconvenience.

August 20. 2013
In v1.171 i have fixed a typo preventing you from getting the loginName when using it to get the value from a people picker field in SP2013. I have also changed how getFieldValue handles people pickers in SP2013 by using the built in methods to get the field value.

When using getFieldValue to get a people picker value on page load, you must wrap the call like this:

	var myPeoplePickerValue = getFieldValue("MyPeoplePickersFieldInternalName","","; ","loginName");

I have updated spjs-utility.js to v1.17 with these changes:

  • Fixed compatibility issue in SP2013 with RTE fields and people picker fields.
  • Added support for getting and setting “Managed metadata fields” or “SPFieldTaxonomyFieldType” and “SPFieldTaxonomyFieldTypeMulti”.

This file is used in multiple solutions – like this one.


Dynamic Forms for SharePoint v3

Change log
Always test a new version to see that it works as expected before adding it to a production environment.

June 19. 2014
v3.352 has these changes:
Fixed the following that went missing in v3.350:

  • Added back the content type choice as trigger and selectable field.
  • Added back the file name field as trigger and selectable field.
  • Added back the additional lookup column fields to the DispForm configuration.

June 10. 2014
v3.351 has these changes:

  • fixQuirkyLookup: Added title attribute to the select for compatibility with SPServices
  • Added back the Attachment field as this had disappeared from the field select in the tabs in v3.350.

June 7. 2014
v3.350 has these changes:

  • The method for reading the fields for the list in the configuration GUI has changed. I now query the list schema for the fields rather than finding them from the current form. This means that you can now configure DFFS for a form with content types without having to add all fields to the default content type. Please note that only the fields in the active content type will be available to the script when NewForm, DispForm or EditForm is rendered.
  • Lookup columns containing more than 20 items in SP 2007 / 2010 using Internet Explorer (quirky lookup columns) can now be used as triggeres. If you are NOT using SPServices cascading dropdown you must tick “Fix quirky lookup columns” in the Misc tab.
  • Triggers are now organized in more “optgroups” to clarify how they trigger (on load, on save etc.)
  • The “doSetFieldValue” function have been changed to support setting Cascading dropdown value using the “Set field value” action in the rules. Please update the cascading dropdown plugin to v3.24 or above.
  • You can now manually specify the location of the DFFS configuration list. This may come in handy when using DFFS in a list template. See separate heading in the bottom of this article.

May 8. 2014
v3.343 has these changes:

  • Changed how the plugin tabs are shown if the plugin is not loaded: the tab will contain a link to download it.
  • Changed how the configuration is done for the resource management plugin.
    Setup is now done in a separate tab and you must remove any configuration from the Custom JS section in the Misc tab.

May 1. 2014
v3.342 has these changes:

  • Changed how the SPFieldMultiChoice events are triggered. It was initially on “click” and now it is on “change”.
  • Added “is changed” trigger on SPFieldChoice, SPFieldMultiChoice and SPFieldBoolean.
  • Changed a little bit on the “is changed” comparison to catch change BACK TO what was the initial value when the form was loaded.

April 25. 2014
v3.341 has these changes:

  • Navtabs now operates in a circular motion: When passing the last tab, it will start from the first tab again.
  • Added check to see if the attachment field in not part of any tab. If so, the attachments will show in all tab.
  • Added option to disable individual rules by a checkbox in the top right corner of each rule.

Only “dffs_min.js” is updated.

April 20. 2014
v3.340 has these changes:

  • Fixed setQuirkyLookup so that getFieldValue will pick up the correct selection if you use it in PreSaveAction.
  • Added support for the new version of SPJS Resource Management:
  • Moved password to Misc tab.
  • Displayed the plugin version used for the various plugins like vLookup, Cascading Dropdowns etc.

April 7. 2014
v3.336 has these changes:
Changed the offset of the custom edit item image in the ribbon for SP2013 as Microsoft uses different image maps in 365 and on premises install of SharePoint – resulting in the wrong image being displayed.

April 3. 2014
v3.335 has these changes:
Fixed bug related to “orphans tab” not working after update in v3.333. Please note that the id of the tab <lt> has changed from “tab_orphans” to “dffs_tab_999”. This affects any custom code you may have used to style or attach events to this tab.

March 22. 2014
v3.334 has these changes:
Changed an alert for when you are trying to hide the active tag by a rule.

March 21. 2014
v3.333 has these changes:

  • Fixed compatibility with SP 2007 and IE8 running on Windows XP.
  • Changed / fixed tab selection by url (?sTab=X), by cookie or when one or more tabs are hidden by rules.
  • Fixed a bug in showing field description with readonly fields when the field description has a trailing <br>.
  • Fixed a bug with using “selected tab index” as trigger in rules (the selected tab index was not always updated on click.

March 17. 2014
v3.330 has these changes:
Fixed a bug from v3.329 where the form was hidden if you had not configured tabs.

March 16. 2014
v3.329 has these changes:
Fixed initial tab selection if the primary tab is hidden by a rule. In this scenario you would have no selected tab, but the form would still be visible. The code will now try to select the next visible tab. If no tabs can be selected, the form i hidden.

March 15. 2014
v3.328 has these changes:

  • Fixed “Selected tab index” in Misc tab. This was disabled by the cookie introduced in v3.320. The selection will still be remembered by the cookie, but on the first visit to this tab in this browser session it will preselect the tab from the Misc tab.
  • Added option in the Misc tab to control the use of cookie for remembering the selected tab.
  • Disabled the “selected tab” cookie for NewForm.

v3.326 has these changes:
Changed dffs_PreSaveAction() to be able to return false to abort the save process. Returning true or nothing will proceed with the save.

v3.325 has these changes:

  • If there is a function “dffs_Ready()” in the CEWP or in the Custom JS, this will be called when the DFFS solution has finished loading.
  • Added “is changed from initial value” trigger to choice columns as this was missing.
  • Added MUI support to the tab navigation buttons.

March 5. 2014
v3.323 has these changes:
Fixed a random error message: [DFFS: spjs.dffs.loadAndApplyRules]: Configuration error.

March 4. 2014
v3.322 has these changes:
Added back the missing “extra” edit item button to the left of the “Cancel” button. This had disappeared in v3.20.

v3.321 has these changes:
Removed a trailing comma in an object (introduced in v 3.32) that broke the script in IE8.

March 1. 2014
v3.32 has these changes:

  • Error in description for the trigger “If logged in user is in group with ID”.
  • Duplicated edit button in some situations.


  • Added alert to catch use of “And these rule indexes are true” looking at a rule that has a higher index than the current rule.
  • Added option to turn on/off the “Fix quirky lookups” feature introduced in v3.3. You find the option in the Misc tab.

New features

  • Added a cookie to remember selected tab trough page refresh.
  • Added new trigger “is changed” for text / number fields. This triggers on any change in the field. The existing trigger with the same name has been renamed to “is changed from initial value” (existing configurations will be automatically updated).
  • New config options for cascading dropdowns: Autofill and Clear invalid. Please note that you must update the cascading dropdown solution separately for the new features to be supported.
  • Added options to show navigation buttons to switch tabs. You find the setting in the Misc tab.

February 17. 2014
v3.315 has these changes:

  • Added “Run these functions” feature to DispForm.

February 13. 2014
v3.314 has these changes:
Attempted to fix an issue with having multiple triggers on “Selected tab index”, where only the last rule applied.

January 29. 2014
v3.313 has these changes:
Fixed a bug in “setQuirkyLookup” for SP2007 as the id of the hidden input field contained characters that needed to be escaped.

January 25. 2014
v3.312 has these changes:

  • Small fix for dialog size when adding attachments.
  • Triggering on date fields now properly supports “Equal to” = [empty string].
  • Fixed bug that halted the script when using ID as trigger in EditForm.
  • Fix for timing issue in SP 2013 that resulted in triggers not picking up the correct value.
  • Added a handful of missing semicolons and minified the code using packer by Dean Edwards.

You can now use the minified version of dffs.js. Pick it up in the download section.

January 21. 2014
v3.311 has these changes:

  • Removed check for fields that were set as required in the list settings as this produced an error in “spjs.dffs.clear_Mandatory”.
  • Fix for SP 2007 compatibility for the “Fixes the quirky dropdown select” added in v3.30.
  • Attempted to fix the randomly missing scrollbar issue in dialog boxes.

January 4. 2014
v3.31 has these changes:

  • Added option to fix the dialog to the top of the screen to prevent it from jumping around when you change tabs. This applies to SP 2010 / 2013 and can be found in the Misc tab.
  • Addressed an issue with spjs.dffs.clear_Mandatory and fields set as requires in the list settings.

December 21. 2013
v3.3 has these changes:

  • Added operator “is changed”. This is used to trigger a rule if the field value has changed after the form was loaded.
  • Added trigger “Compare logged in user with people picker field”. This can be used to trigger a rule if the logged in user is or is not selected in a given people picker field.
  • Fixed tooltip left adjustment to prevent the text form rendering outside the screen when using side-by-side.
  • Added z-index:1001 to the tooltip container to fix a rendering issue in SP2013 where some elements shined trough the container.
  • Tried to fix an issue with setting a people picker to readonly in SP2013 and getting a “field is not ready” error. I could not reproduce this error and therefore cannot promise this will fix it.
  • Fixes the quirky dropdown select in Internet Exploree used for a single lookup column when there are more than 20 items in the lookup source list (SP2007 and SP2010).

You must update both the “DynamicFormsForSharePoint_v3.js” and the “default.css”.

Please note
I no longer have access to a SP 2007 environment and therefore I cannot guarantee compatibility with SP 2007. If you use this solution with SP 2007 you must add this variable to the page for compatibility with v3.3+:

var _spPageContextInfo = {"pageListId":"{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"};

You must change the string “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” with the list GUID of the current list. You should be able to find it by viewing the page source and searching for “ctx.Listname” (SP 2007).

November 28. 2013
v3.262 has these changes:
Fixed bug with attachments due to a function changing the id “idAttachmentsRow”.

v3.261 has these changes:
Fixed a bug in v3.26 regarding L_Menu_BaseUrl.

November 24. 2013
v3.26 has these changes:
Added a check for a function named “dffs_PreSaveAction” when saving the form. Use this function to add “pre save code” like this (the function must NOT return anything):
function dffs_PreSaveAction(){
// do stuff before saving
November 21. 2013
v3.25 has these changes:
Yet another fix for detecting folder content types and summary tasks in a tasks list.

November 17. 2013
v3.23 has these changes:

  • Better detection of “New folder” to prevent the DFFS code from triggering.
  • Tooltip now supports vLookup columns that use “Hide form label”.
  • Set field value now updates the value in readonly fields.

November 3. 2013
v3.222 has these changes:

  • Removed the paperclip in front of the “Attachments” formlabel as adding attachments is not possible in DispForm.
  • Fixed undefined variable “isNewForm” > “”.
  • Added description to the tooltip section: If you use HTML code, do not add line feeds using Enter, add HTML code as a continuous string.
  • Hide save item btn now works both ways: No = show button.
  • Added option to hide edit item btn in DispForm. This works like the “Hide save item button”.

October 31. 2013
v3.221 has these changes:

  • Fixed unnecessary escaping og double quotes in object formatted strings (bug introduced in 3.22).
  • Fixed missing tabs in SP2013 Document library.
  • Fixed bug where sometimes the config is not recognized due to wrong case in the URL.

October 28. 2013
v3.22 has these changes:
Replaced a custom stringify method with the standard JSON.stringify. This because the custom method failed in some rare cases. This change will affect SP2007 when using IE. Because the master page forces Document Mode: Quirks, you must use another browser, or force the Document mode to IE8 using the developer console.

October 27. 2013
v3.21 has these changes:

  • Edit item button will not show in DispForm if the user does not have edit access.
  • Set Field Value now supports all available properties from the user list in SharePoint (not the user profile service). Use it like this: {currentUser:Prop}.

October 21. 2013
v3.20 has these changes:

  • Side-by-side: Label position can now be set to “Hidden”, “Top” or “Left”.
  • You can add attachments by clicking the paperclip in front of the Attachments label.
  • Added id attribute to the table row in this format: dffs_[FieldInternalName]. You can use this to address individual fields using custom code.
  • Comparing field values against other fields in the form is now supported for number columns (and text columns containing numbers)
  • Fixed an issue with “Set field value” using a value pulled from another field when the first character is not “{“.
  • “Set field value”: {timestamp} – see details below.
  • “Set field value”: {currentUser} and {currentUserEmail} – see details below.
  • “Set field value”: Prepend or append to existing text – see details below.
  • Creating a new folder now bypasses the DFFS solution.
New features in the “Set field value” section

Use {timestamp} to add a timestamp to a field.

Current user
Use {currentUser} or {currentUserEmail} to add the user name or the email (malito link) in a field.

Prepend or append to existing text in a multi line text field:
Prefix the string with “prepend:” or “append:”. Here is an example:

prepend:{timestamp} - {currentUser}: {Log}\n************\n

September 18. 2013
I have updated to v3.15 with these changes:

  • Initially hidden field can not be made visible by including them in a tab – you must use a rule.
  • Fixed set field value for multiline textfield

September 13. 2013
I have updated to v3.14 with these changes:

  • Fixed bug in clearing / reversing rules for unselected choice columns. This bug would incorrectly trigger the rule when clicking another option in the choice columns.

September 12. 2013
I have updated to v3.13 with these changes:

  • Fixed typo “dropdodwns”
  • Changed the CSS file to make the form look the same in DispForm and EditForm when using side-by-side.
  • Added trigger for “Selected tab index.
CSS when using side-by-side

Insert this CSS in the Custom CSS section in the Misc tab if you want to:

stretch the outer table for all rows of side-by-side fields


stretch the outer table for a specific row of side-by-side fields

#sbs_OuterTR_1 .sbs_OuterTable{

sbs_OuterTR_1 the highlighted number represents the side-by-side index used in the setup.

control each field when using side-by-side

Trigger “Selected tab index”

This trigger is used for triggering rules when clicking on a tab. Please note that the rule will be reversed when it does NOT match.


Lets say you want a field to trigger a rule for one tab only. To achieve this, first create a rule using “Selected tab index”, but leave all “actions” empty (no required fields etc.).

Now create the rule for the trigger field and insert the rule index of the “Selected tab index rule” in the “And these rule indexes are true”.

You now have a rule that triggers on a field, but only applies for this specific tab.

August 19. 2013
I have updated this solution to v3.1 withe these changes:
New features:

  • Added support for Cascading dropdowns – see separate article for detail.
  • Added option to enter a license code to remove the PayPal-logo in the top of the GUI.


  • Removed “Set field value” from the DispForm configuration.
  • Fixed a bug preventing “Set field value” using [Today].
  • Fixed a bug when triggering a function in a rule on load.

You must update both the *.js, the *.css file and spjs-utility.js.

August 13. 2013
Second attempt with v3.02: fixes a bug preventing the user from saving the first time the configuration is added.

How to remove the text “Unlicensed version” from the GUI?

To obtain a license code, please go to this page: Obtain License Code, select the license type and pay using PayPal. I will send you a license code as soon as i receive the receipt from PayPal.


This is a solution for creating dynamic forms from out of the box SharePoint forms (preferably without content types). You can create rules that control whether fields are required or optional, visible or hidden, editable or read-only. You can also create tabs that you can target specific SharePoint users or groups, and you can add headings and rich tooltips for fields in the form.

You can link directly to a specific tab using this URL format:
…/DispForm.aspx?ID=[an existing id from your list]&sTab=2
…/EditForm.aspx?ID=[an existing id from your list]&sTab=2

The GUI:

Previously articles in this series
New in v3

I have done a major overhaul of the code, fixed some bugs and added new features:

  • Radio buttons can now be arranged vertical.
  • When arranging multichoice or radio buttons vertical, the “fill in” will line up correctly.
  • Fixed width of select when using “Arrange multi lookup columns vertical” in SP 2007.
  • Custom CSS and JS: Small fix to try to avoid occasional errors.
  • Export and import of settings are now in place.
  • A copy of the last good configuration is automatically kept, and can be restored by a click of a button if you “break” it.
  • Backwards compatibility is now better. Please note that downgrading to an older version will require you to restore a backup of the original setup.
  • Changed the rule builder and added more fine grain controls of:
    • Optional fields and required fields
    • Visible fields and hidden fields
    • Editable fields and read-only fields
    • Visible tabs and hidden tabs
    • Visible headings and hidden headings
  • “Display this message” and “Alert this message” is now present in DispForm.
  • You can now control who sees the enter setup button.
  • You can now control who sees the orphan fields tab.
  • You can now distribute tabs over multiple lines and not only 2 as before.
Manually specify the location of the DFFS configuration list

Why do it:
If you want to use DFFS in a site template and share the configuration between all the sites created from that template.

The configuation is stored using the list name from the URL in lower case letters as “unique identifier” like this:
This means you cannot configure DFFS for a list with the same URL name in a different site without them sharing this configuration.

How is it done:
Add this variable to the CEWP or HTML Form Web Part code (above the script tag that loads the DFFS script):

var dffs_configListBaseUrl = "/RelativeUrlToTheSite";

You don’t have to put the shared configuration in the root site, you can add a new, empty subsite to hold the configuration list, but you must ensure all users have read access to this site.

Repetition of how to set up this solution

Step one
Download the latest version of the DFFS solution files from here. This includes the *.js file, *.css file and the This last one should be unzipped before uploading to the file location (see below).

Step two
Download the latest version of spjs-utility.js from here.

Step three
Download v1.10.x or BELOW of jQuery here. Please note that version 2.x of jQuery does NOT support Internet Explorer 8 or below.

Step four
Put all these files in a standard document library or a folder created using SharePoint designer. Ensure all users have read access to the file location. Do NOT refer these files from as this server is not rigged to serve these files “live”.

Step five
Download the files “CEWP_example.txt” and “CEWP_Overlay_Example.txt” from here. Edit the script links (src) in “CEWP_example.txt” to point to the files stored locally. I repeat that you should NOT refer these files from

Add the code to NewForm, DispForm and EditForm of the lists where you want this solution activated. The “CEWP_Overlay_Example.txt” must be placed ABOVE the form web part, and the “CEWP_example.txt” code must be placed BELOW the form web part.

How to add a webpart to the form page
SharePoint 2007
Go to NewForm, DispForm and EditForm and insert toolpaneview=2 behind the URL in this format:
…/DispForm.aspx?ID=[an existing id from your list]&toolpaneview=2
…/EditForm.aspx?ID=[an existing id from your list]&toolpaneview=2

Press Enter and you should be able to add a CEWP to the page. Repeat for all three forms.

SharePoint 2010 / 2013
In the list view, click “List” on the List Tools menu. Then select “Form Web Parts” and pick NewForm, DispForm or Editform from there and add a CEWP to the page. Repeat for all three forms.

I recommend using the Content link option in the CEWP to refer the code. The CEWP code should be put in a text file (txt) or an aspx file and put in the same location as the other files.

If you plan to put the code directly into the CEWP, you should choose the HTML Form Web Part in stead.

Step six
Go to the list and click “Add new item”. Click the little dot in the bottom left corner of the form to enter setup. When entering setup for the first time, the script will create a list to store the configuration. For help in the GUI, hover over the question marks.

Upgrading from a previous version?

You will have to upgrade both the *.js, the *.css file and spjs-utility.js.

As this is a major overhaul of the code, you might have to do some reconfiguring of the rules. In general, all settings are kept, but you now have more fine-grain control of the various settings so some rules might have to be changed.

Make a backup
When entering the setup after loading the new version, go to the “Misc” tab and export the settings by copying the text to a file. This is your backup in case something goes wrong and you have to downgrade to an earlier version. If you must do this, use the backup file and restore it by pasting the text in the text area under “Import settings”. When you have done this, you can load the older version of the script.

Please support the development of this solution by hitting the “beer button” in the top right corner of this page to buy me a few beers.

Use the comment section below let me know if you find find a bug, or you have a question.


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!


Customized forms using SharePoint Designer – how to use the init_fields function

Change log
June 27. 2013
I have changed the function “init_fields_customForm()” to properly set the “fieldType” and “fieldDispName” in the fields object.

This is a repost of a previously published article. I have updated the code examples for compatibility with newer solutions. I cannot guarantee that this code will make all my various solutions work in a modified form as some of the solutions have a variant or the init_fields function embedded and you would have to modify it in the *.js file for that particular solution, but it will give you an idea on how it works.

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”:

<!-- FieldName="This is the DisplayName"

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="(.+)"\s+FieldInternalName="(.+)"\s+FieldType="(.+)"\s+/);	
			// Display name
			var disp = myMatch[1];
			// FieldInternalName
			var fin = myMatch[2];
			// FieldType
			var type = myMatch[3];
				}else if($(this).find("div[id$='_TextField_inplacerte']").length>0){
			// Build object
			res[fin] = this.parentNode;
	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().

To achieve this, we add an id attribute to the <TD> that holds the ms-formlabel.

Here is an example of code from a customized form:

	<td width="190px" valign="top" class="ms-formlabel" id="TitleColumnCustomID" fieldType="SPFieldText" fieldDispName="Title">
		<H3 class="ms-standardheader">
			<nobr>Title<span class="ms-formvalidation"> *</span>
	<td width="400px" valign="top" class="ms-formbody">
		<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
		<SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="New"/>

Note the id, fieldType and fieldDispName:
id=”TitleColumnCustomID” fieldType=”SPFieldText” fieldDispName=”Title”

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

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

The field type attribute is essential to get right for the functions “getFieldValue” and “setFieldValue” to work!

List of field type identifiers
Field type FieldType identifier
Singele line of text SPFieldText
File name SPFieldFile
Number SPFieldNumber
Currency SPFieldCurrency
Single choice column SPFieldChoice
Multi choice column SPFieldMultiChoice
User SPFieldUser
Singel lookup SPFieldLookup
MultiLookup SPFieldLookupMulti
Boolean value (Yes/No) SPFieldBoolean
Hyperlink or image SPFieldURL
Date and time SPFieldDateTime
Multi line of text SPFieldNote

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

fields = init_fields_customForm();
var myTitleFieldValue = $(fields['TitleColumnCustomID']).find("input").val();

Ask if anything is unclear.


Dynamic Forms for SharePoint: Now with field tooltip

Change log
June 03. 2013
Changes in v2.981

  • Added Danish date format (LCID 1030).
  • Added option to arrange multilookup columns vertically.
  • Changed the identifier for the headings to prevent them from getting a new ID when they are moved or another heading is deleted.
  • Fixed a bug setting a multichoice column as mandatory using the fill-in option.

Multichoice columns vertical:

May 20. 2013
Changes in v2.98

  • Added support for arranging checkboxes (choice columns – allow multiple selections) in multiple columns. You find it under the Misc tab.

This update requires you to update the *.js and the *.css.

May 16. 2013
Changes in v2.971

  • Fixed required field check for multichoice columns.

This update requires you to update the *.js.

May 13. 2013
Changes in v2.97

  • Fixed missing trigger for Currency field.
  • Added option to initially hide a list of fields. This option is found under the Misc tab.

This update requires you to update the *.js.

May 13. 2013
Changes in v2.961

  • Fixed a bug in bringing fields visible when NOT using Tabs.
  • Cosmetics: Hidden the “Edit button” behind an image. Update the CSS file to have it initially hidden.

This update requires you to update both the *.js file and the *.css file.

May 10. 2013
Changes in v2.96

  • Disabled the solution when the page is in edit mode to prevent errors.
  • Fixed a glitch in “reversing” rules when using multichoice checkboxes.
  • Attempted to fix a chrome issue with disappearing scrollbars.
  • Added an option to include an overlay with “Loading, please wait…” to prevent flashing the unformatted form when loading – see details below.

In this release only the *.js file has changed, but if you want to use the overlay, follow the instructions below.


If you have some errors in your setup, or you do not have the latest version of the DFFS solution (2.96+), you will see this message after 5 seconds:

To use the overlay, place a HTML Form Web part ABOVE the form, and insert this code:

<style type="text/css">
<div id='dffs_loadingOverlay' class='dffsOverlay'>Loading, please wait...</div>
<script type="text/javascript">
		var oDiv = document.getElementById("dffs_loadingOverlay");
		if(oDiv !== null){
			oDiv.innerHTML = "<span style='font-size:20px'>This took forever!<span style='font-size:12px'><br><br>Ensure Dynamic Forms for SharePoint v2.96+ is referred correctly.<br><br>Click to close this overlay.</span></span>";
			oDiv.onclick = function(){
The article

I have updated the Dynamic Forms for SharePoint solution and incorporated the Form Field Tooltip for SharePoint 2007 and SharePoint 2010 solution.

The DFFS solution still supports SharePoint 2007, 2010 and 2013.

New in this release
Added tooltip:

Keep focus on tab through DispForm to EditForm
I have rigged it so that you will keep focus on the same tab when you edit a list item from DispForm.

How to update
You must update both the *.js and the *.css file. Get the latest version of the files from here

If this is the first time you implement this solution, please start with the first article linked above for setup instructions.

Update spjs-utility.js
You should update spjs-utility.js to v1.15 as I have fixed a bug in “getFieldValue” when using “Allow ‘Fill-in’ choices”.

Please comment below if you find a bug – or you like this solution.