All posts by Alexander Bautz

Cascading dropdowns updated to v3.30

I have posted a small update to SPJS-Casc.js to fix these issues:

  • 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.

Get the updated version here

You find the article describing the solution here, and you find the dedicated forum here.

Alexander

SPJS-Utility.js is updated to v1.200

I have updated SPJS-utility.js to v1.200. I have changed the file so all functions are now part of the “spjs.utility” namespace. I have included support for existing code using the old function names as well. There are not many changes to the functionality, but a few small changes to setFieldValue and getFieldValue related to various bugs reported from DFFS.

Get the updated version here

This file has always contained “internal” functions used in various solutions, but you can use the functions in your custom code. Unfortunately there is not documentation made at this point, but you can post questions in the SPJS-Utility forum.

Alexander

SPJS-Lookup: Convert a single line textfield to a dropdown select based on a query

Change log

You find the latest change log here: https://spjsblog.com/dffs/dffs-change-log/

v1.11 (August 17, 2015):
Fixed an error resulting in existing values not validating when loadign an item in EditForm.

v1.10 (February 28, 2015):
If you want to have the same list of choices in multiple fields, you can now populate an unlimited number of fields from one single query. All you have to do is to use an array of fields in the parameter “fieldToConvertToDropdown”. See code example below for details.

v1.05 (February 12, 2015):
Added option to specify a folder in the query. The custom CAML or query will search only in the specified folder. Please note that you must update spjs-utility.js to v1.205 or later.

v1.04:
Removed a border around an image that occurred in SP 2010.

v1.03:
Fix for “addToExternalList” when using the solution for multiple fields in a form, and more than one targetted the same lookup list. The callback would refresh the bottom SPJS-Lookup field as the “argument object” was not uniquely identified.

January 21, 2015
v1.02:
Fixed a bug where I had mistakenly used the display name and not the FieldInternalName as identifier for the fields.

This is a remake of a solution I posted in 2009. It does mostly the same as the old one, but the code is overhauled, and it is now compatible with DFFS.

What does it do?

This solution is used to convert a single line of text field into a dropdown select. The options for this select is the result of a query you build in the function call. You can use it to query any list within the same site collection. You have an option to add new values to the “lookup list” on the fly, or to enter a value free hand.

This solution is compatible with SP2007, SP 2010 and SP2013.

DFFS plugin

This is compatible with DFFS, but you will not find a dedicated “tab” in DFFS to set it up. You must therefore use the same code for both DFFS and standalone use. With DFFS you have the option to put the function call in the Custom JS section in the Misc tab.

The code

If you use it as a standalone solution, you must refer jQuery and SPJS-utility.js in addition to SPJS-lookup.js.

In a standalone setup it will look something like this
<script type="text/javascript" src="/code/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="/code/spjs-utility.js"></script>
<script type="text/javascript" src="/code/spjs-lookup.js"></script>
<script type="text/javascript">
// Put the contents from the code block below here.
</script>

If you use it with DFFS, the only extra script you need is this (in the DFFS_frontend CEWP) – put it below the reference to spjs-utility.js:

<script type="text/javascript" src="/code/spjs-lookup.js"></script>
The function call
spjs.lookup.init({
	"fieldToConvertToDropdown":["MyTextField"],	
	"listName":"Tasks",
	"listBaseUrl":"/Sites/MySite",
	"optTextFieldInternalName":"Title",
	"sortFieldName":"Title",
	"filterObj":{
		"on":true,
		"folder":"", // Leave empty to search in all folders
		"CAML":null, // If used, the rest of the filterObj settings are disregarded
		"fin":"Completed",
		"isLookup":false,
		"operator":"Neq",
		"filterVal":"1"
	},
	"dropDownDefaultvalue":"...",
	"addYouOwnValue":{
		"on":true,
		"linkText":"Write your own value"
	},
	"addToExternalList":{
		"on":false,
		"customFunction":null, // Function name as a string. If a function name is supplied, this will be used in stead of the default function. The function will be passed the argument object as a parameter.
		"linkText":"Add new item",
		"saveNewItemText":"Save new item"
	},
	"debug":false
});
Parameter details
  • fieldToConvertToDropdown: This is an array or FieldInternalNames of the fields in the current list that you want to convert to a dropdown. Specify multiple fields like this: [“FirstField”,”SecondField”] to have all server the same options based on one single query.
  • listName: This is the display name or the list GUID of the list you read the options from.
  • listBaseUrl: This is the base URL of the list you read the options from. If the list is on the root site of your domain, the value will be an empty string like this “”. If it is on a managed path, it will be something like this: “/Sites/MySite”
  • optTextFieldInternalName: This is the FieldInternalName of the field that represents the options you want to show in the dropdown select.
  • sortFieldName: This is the FieldInternalName of the field you want to sort the options by. Most likely the same as “optTextFieldInternalName”.
  • filterObj
    • on: true or false to tell if the options should be filtered. If false, all options will be shown.
    • folder: Here you can provide a relative URL to a folder like this: /Sites/MySite/Lists/MyList/MyFolder/MySubFolder
    • CAML: Here you can provide the full CAML query to filter by. If this is left as null, the other options below will take effect.
    • fin: The FieldInternal name you want to filter on.
    • isLookup: true or false. If you filter by a text value, use false. If you filter by an ID in a lookup field, set it as true.
    • operator: Use anu valid CAML operator like “Eq”, “Neq”, “BeginsWith” or “Contains”.
    • filterVal: This is the value you want to filter by.
  • dropDownDefaultvalue: This is the default value in the dropdown when it has not been selected.
  • addYouOwnValue
    • on: true or false. This controls whether or not to show a link to “kill” the dropdown and show the underlaying text field.
    • linkText: This is text on the link.
  • addToExternalList
    • on: true or false. This controls whether or not to show a link to add an item to the list you are pulling the options from.
    • customFunction: If you want to override the built “addToExternalList” function, add your custom function name here like this: “myAddListItemFunc”. The function itself must be present in the page, and it will get the full “argObj” passed to it as a parameter.
    • linkText: The link text that initiates the “addToExternalList” function.
    • saveNewItemText: The text on the “save” link.
  • debug: true or false. If true, the underlaying text field will not be hidden, and you will see a yellow information panel in the top of the page.
Setting a value in a field with this solution activated

To set the value of a field when using this solution, use code like this:

spjs.lookup.setValue("FieldInternalName_of_your_field","The value you want to set");

This will also work with DFFS and will trigger any rule currently configured for the underlaying text field (by triggering the blur-event).

Questions or feedback

Please use the forum for all questions related to this solution.

Alexander

vLookup for SharePoint 2010-13 v2.100 BETA

I have published a BETA version of vLookup Frontend with these changes:

  • Fixed a bug where number columns could not use the “css” set in vLookup setup.
  • Changed how the list name is picked up from the URL as this would fail in some cases – as described here.
  • Added support for settings SPFieldLookupMulti fields when creating children – as requested here.
  • Changed the $ to spjs.$ as I did in the latest BETA of DFFS due to an error in SharePoint when using rich text fields and “Insert > Link > From SharePoint” as the file “assetpicker.js” will “kill” jQuery by overriding the global $ variable.

Get the latest BETA version here (ensure you pick the latest one).

This is released as a BETA due to the changes in how jQuery is referred. Please post any findings or questions in the forum.

Best regards,
Alexander

DFFS v4.210 BETA

BETA 2 of DFFS frontend released January 19, 2015
Please note that this version is BETA and is NOT intended for a production environment.

I have released a new BETA version (v4.210 BETA) of DFFS, but I need help testing it as I have made some fundamental changes to how “initial values” are retrieved, and to how read only fields are “styled” to maintain the correct width of the field. There are also a quite a few bugfixes and other changes that I would like your feedback on.

The full change log is as follows
Changes and new features
  • Changed how read only fields are “styled” when using side-by-side to try to maintain the width of the field. This change needs testing – let me know how it works in your setup.
  • Changed how initial value is retrieved when the form loads. Previously DFFS read the values from the fields using the function “getFieldValue”, but now it uses a web service call to get the current item metadata from the DB. This is done to try to overcome the problems some have been experiencing with people pickers not being ready when set to readonly when the form loads. This change needs testing – let me know how it works in your setup.
  • Changed how you reorder fields in tabs in the backend.
  • Boolean values will be displayed as checkboxes in DispForm.
  • New: Changed tab color on hover to a slightly lighter color (update CSS file for the frontend).
  • Added class “dffs-accordion-activePanel” to active accordion panel. You can use this class for your “custom code”.
  • New: Added support for comparing dates with hours and minutes. Please note that you cannot use hour and minute when comparing dates in DispForm.
  • New: Added “between” operator.
  • New: You can now add a new field to the list from the Misc tab (SP 2010 and 2013 only).
Bugfixes
  • When no configuration has been created for a form, the overlay would time out with “This took forever”.
  • When using side-by-side and hidden label you could got a linefeed after the star that indicates that the field is required.
  • Selected tab index trigger: added “change event” as this trigger only fired on load and not on change of tab.
  • Only the first rule using the trigger “Selected tab index” could be used in “and these rules are true”.
  • The rule debug output was missing “run these functions”.
  • Date pickers: In some cases, errors would appear in the developer console in SP2013 when operating date pickers.
  • Date pickers: The “blur” event was not triggered on the “master” datepicker when using “linked” datepickers and modifying the “slave”.
  • When a field was configured in DFFS, but it was not in the current content type, you could in some cases get an error like “unable to get the property “hidden” of undefined or null reference” in the developer console.
  • The Attachement field will no longer trigger the “orphans” tab.
  • In the frontend I have changed from referring jQuery as $ to use spjs.$ due to an error in SharePoint when using rich text fields and “Insert > Link > From SharePoint” as the file “assetpicker.js” will “kill” jQuery by overriding the global $ variable. This would result in a complete halt in all the functionality in DFFS (and other plugins using jQuery). Please note that other plugins must also be updated. Look at the change log for each one to see which one have been updated.
  • Scroll to first input will no longer make the form scroll down. If the first input is off the visisble sceen, it will not get focus.
  • BETA 2: Fixed bug occurring when you for some reason had duplicates of the configuration in the configuration list. Now only the first “match” will be used, and you will no longer see duplication of rules and tabs.
  • BETA 2: Fixed a bug where “rule messages” did not show for readonly fields.
  • BETA 2: Fixed a bug in setting field value for a date only field when this is read only. It will now show date only and not date and time. Please note: You must also update spjs-utility.js to v1.200 or later.
Get the BETA version here

Follow this link, and ensure you get the latest version. PS: The files are uncompressed, therefore the files are bigger than the production release.

Give feedback in the forum

Please post any findings or questions regarding the 4.210 BETA in this topic in the forums.

Unfortunately I have not been able to test this as thoroughly as I wanted, but I could not wait any longer to make it available. Post any findings to the forum, and I will fix the issues as soon as I can manage.

The more of you that gives feedback, the faster the production version will be released!

Best regards,
Alexander

vLookup for SharePoint v2.0 is out

I have finally released v2.0 of my vLookup solution. There are a few new features, and it is better integrated into the DFFS backend.

You find the complete change log here.

Please note that this version does not have the “editor” built in to the frontend and you can no longer configure vLookup by adding ?vLookupSetup=1 to the URL. You must now configure vLookup from the DFFS_backend in the vLookup tab.

There has been some major changes to the code and you must test it in your setup before adding it to a production environment.

Folder support

One of the new features lets you have folders as children (in document libraries).

This way you can now add a folder from the vLookup “add child” link and have vLookup show all documents and subfolders added to this folder.

The metadata that makes the connection to the parent item is now on the folder and not the individual document.

Any documents uploaded to this folder will show in the parent item and there is no need to tag the individual documents with a connection to the parent item. It will show all documents and subfolders that are added to this parent folder.
IMG

I have also finally crated a user manual that describes the setup process and all the configuration options.

Get the new version

You find the link to download the new version in the Products menu in the top of this page.

Questions, comments or bugs

Please post any questions, bugs or feature requests in the forum.

Alexander