← vLookup

vLookup user manual

Show related items from another list or library in a DFFS form, and add, view and edit them there. vLookup is built into Classic DFFS. Applies to vLookup v2.2.171 (configuration v2.2.172) in Classic DFFS v5. Step by step: the setup example.

What vLookup does

vLookup links items in two lists or libraries, a parent and its children, and shows the children in the parent’s form as a table: order lines on an order, tasks on a project, documents on a case. Users can open, edit and add children from the parent form, and new children get the link to the parent and other values filled in. The link is either a lookup column in the child list or a value in the child that matches a value in the parent.

vLookup is part of Classic DFFS and licensed with it; there is nothing separate to buy or install. It needs a Professional or Enterprise license (every license issued before v5 is Professional).

Setup

Before you start

  • Install DFFS in the parent list’s forms. vLookup loads with DFFS; there are no extra files to add.
  • Add a column to the parent list whose internal name starts with vLookup, for example vLookupTasks. It holds the vLookup table in the form. The internal name is set when you create a column, so create it as vLookupTasks and change the display name afterwards (for example to Tasks). A parent list can have several vLookup columns.
  • Save the form’s DFFS configuration at least once before you configure vLookup.

The configuration list

vLookup stores its settings in a list named SPJS-vLookupSettings. The first time you open a vLookup column’s settings in a site, vLookup offers to create the list; click OK, and the page reloads.

vLookup offers to create the SPJS-vLookupSettings list

Keeping the list on another site. Set vLookup_configListBaseUrl to that site’s server-relative URL before vLookup loads. For DFFS forms, put it in Custom JS on the DFFS Installer’s Modify the loader file tab and click Update loader file. For list views, add it in vLookup_ListView.html (below) before the line that loads vLookup.

<script>
var vLookup_configListBaseUrl = "/sites/forms";
</script>

vLookup in a list view

vLookup can show its result (for example a count or a list of children) in a list view. Add a Content Editor web part to the list view page with Content Link pointing to /SPJS/DFFS/vLookup_ListView.html. At the top of that file, set dffs_folder_location to where the SPJS library is: "current" (this site), "parent" (the parent site, the default) or "root" (the site collection root). This works only in classic list views, not in the modern SharePoint list experience, and the view must show the item checkboxes: in the view settings, under Tabular View, tick Allow individual item checkboxes. In the column settings, choose List views wherever links and buttons should appear there.

Configuration

In the DFFS configuration, open Plugins → vLookup and click a vLookup column to open its settings card. Every setting has a help icon. The setup example walks through a complete configuration.

Plugins, vLookup, listing the vLookup columns
The vLookup tab lists the vLookup columns.

The child list

SettingWhat it does
Disable this vLookup fieldTurns the column off, for example while you build or troubleshoot.
Note to selfYour own notes.
List base URLThe server-relative URL of the site with the child list, for example /sites/projects; / for the root site; {currentsite} for the current site (works when the site is saved as a template).
List GUID, display name or URL nameThe child list. A URL name needs the prefix url: (url:Tasks) and costs an extra request when the form loads. A variable works too: {var:name}. Use the GUID in multilingual sites, where display names differ per language. A list’s GUID is _spPageContextInfo.pageListId in the browser console on one of its views.
Verify connection to listChecks the two settings above. It cannot check a url: name or a variable.
List of available fields for the child listShows every field in the child list with its FieldInternalName, for use in the query and the columns.

Which children to show

Build query: one or two conditions joined with And or Or. For each: the child field’s FieldInternalName, its type (Text, Number, Lookup (id) or Lookup (text value)), an operator (is equal to, is not equal to, is greater than, is less than, is greater than or equal to, is less than or equal to, begins with, contains, is null, is not null) and a value. In the value:

  • [currentItem:FieldInternalName]: a field of the parent item, for example [currentItem:ID];
  • [URL:Key]: a value from the URL;
  • [me]: the current user, for a people field or Author / Editor (use is equal to or is not equal to; the type is ignored);
  • {var:name}: a variable from Custom JS.

Write your own CAML-query replaces the built query, for anything more complex. The same [currentItem:…] and [URL:…] values work.

SettingWhat it does
RowlimitShow at most this many children; empty shows all.
Show more items labelWith a row limit: the text the user clicks to load the rest. MUI supported.
Limit the height of the child tableHeight in pixels; taller tables scroll.
Order byUp to three fields, comma separated, each with :true (ascending) or :false: Title:true,Created:false. Empty sorts by ID.

Columns (ViewFields)

The child fields to show, in order. For each: the FieldInternalName, the column heading (with translations per language, default as fallback; leave it empty to hide the heading) and optionally a width in px or %. If any column has a % width, or none has a width, the table is 100% wide; with only px widths it sizes to its content. For grouped tables, use % in at least one column or px in all, so the groups line up.

Number and currency columns are shown with the child field’s number format (decimals, digit grouping, %, currency symbol), totals included. A column with its own number options below keeps them; {"noFieldFormat":true} shows the unformatted value.

Special configuration per column, as JSON. Combine options inside one pair of braces, separated by commas: {"prefix":"$","decimals":2}.

OptionExample
Part of a value: split and keep one part{"separator":"|","part":0}
Separator for Comma separated list{"delimiter":"<br>"}
Text before or after the value{"prefix":"$","suffix":""}
File extension on the document name (FileLeafRef){"showFileExt":true}
Date format (HH 24-hour, hh 12-hour){"dateFormat":"dd.MM.yyyy HH:mm"}
Number format; negativeSign is "-", "()" or "red"{"decimals":2,"thousandsSeparator":" ","decimalSeparator":",","negativeSign":"()"}
Percentage (value × 100){"percentage":true,"suffix":"%"}
Progress bar (style it with div.vLookupProgressBarOuter / div.vLookupProgressBarInner and !important){"percentage":true,"suffix":"%","progressBar":true,"progressBarMax":200}, plus optional progressBarPrefix / progressBarSuffix
Show empty values as 0{"nullToZero":true}
Show a picture column as the picture{"picture":true,"maxWidth":"150"}
CSS for the cells, or for the heading{"css":"color:green"}, {"hcss":"text-align:center"}
Replace values, optionally per language or from a variable{"replace":{"0":"Approved","1":"Rejected","2":"Pending"}}, {"replace":{"0":{"1044":"Godkjent","default":"Approved"}}}, {"replace":"{var:name}"}
Your own function: gets the value and the SharePoint list item, returns what to show. Define it in Custom JS{"function":"formatStatus"}
Totals per column (see below){"showTotals":false}, {"totalsType":"average"}
// Custom JS: {"function":"formatStatus"}
function formatStatus(value, listItem) {
    return value === "Late" ? "<span style='color:red'>Late</span>" : value;
}

Totals

  • Show a totals row below the vLookup child table: sums all number columns. Per column, in the special configuration: {"showTotals":false} to leave a column out; {"totalsType":"average"} (average of non-empty values) or {"totalsType":"count"} (also counts text) instead of the sum; {"totalsPrefix":{"default":"Total: "},"totalsSuffix":{"default":" h"}} for text around it, per language.
  • Show a grand totals row below the grouped items, with a grand total label, for grouped tables.

Links, layout and action

SettingWhat it does
Refresh all vLookup columns on changeAfter a child is changed, reload every vLookup table in the form, not only this one.
Show upload / open folder button when hovering over a folderFor children that are folders in a library: buttons to upload documents into the folder, or open it in a dialog, with your own mouseover text.
Hide form label on vLookup columnHides the vLookup column’s label in DispForm and EditForm.
No items found labelText when there are no children, per language.
Table styleOptional looks for the table: Alternating row color (every other row light grey), Frame around table (a rounded border), Buttons on hover only (the view and edit buttons show only when the mouse is over the row; on a touch screen, tap the row first) and Box around no items (the no items label in a dashed box).

The links and the refresh option apply to the action Show all records.

Action: what to show.

  • Show all records: a table of the children.
  • Comma separated list: the values in one line; best with one column.
  • Sum of the values.
  • Average of the values.
  • Count of non-empty values.

GroupBy (not for Comma separated list):

  • FieldInternalName to group by, for example Status; empty for no groups.
  • Expand group: groups start open.
  • Group header style: CSS for the group headings.
  • Group header label: text before the value, for example Status:.
  • Show item count: adds the number of items to each group header.

Adding children

Lets users add a child from the parent form. In a document library the button uploads one document; to add many documents at once, add a folder instead (below).

SettingWhat it does
Configure “add new item”Turns adding children on.
Show add new item buttonIn NewForm, DispForm, EditForm and list views, as ticked. For NewForm, see Adding children from NewForm.
New item button positionAbove or below the table.
Add new item labelThe button’s text, per language.
Add new items to this folderCreate children in this folder of the child list. Empty uses the root (in a library, the user can pick a folder in the upload dialog). [currentItem:FieldInternalName] takes the folder name from the parent.

Prefill values in the child

Fills in fields of the new child, typically the field that links it to the parent. Each row has a From value and a To field (the child’s FieldInternalName). The child’s NewForm must load vLookup (below) to receive the values.

FromFills in
FieldInternalNamethe value of that field in the parent, for example ID or _DFFSID
{Any text}the text in the braces
{currentUser:ID}, {currentUser:EMail} …a property of the current user from the site’s user information list
ItemRelURLthe parent item’s address, /site/list/DispForm.aspx?ID=12
{{var:name}}a variable from Custom JS
key=value, key=[currentItem:Field] or key={var:name}, with {URL} as the To fieldadds the parameter to the child form’s URL

For a date field, add the date format to the To field: StartDate[MM/dd/yyyy]. Hide field in NewForm hides the filled-in field in the child’s form.

Adding folders (libraries)

When the children are documents, you can link a folder to the parent instead of each document: the folder carries the link, and users upload any number of documents into it the normal way. Turn on Configure “add new folder”, choose where the button shows and its position and label, and set Folder metadata (From and To, as above) so the folder gets the field the query links on. From NewForm, set it up as in Adding children from NewForm.

Save, export and import

Each vLookup column is saved on its own with Save configuration, separately from the DFFS configuration of the form. If a vLookup configuration is still open when you click Save (or press Ctrl+S) in DFFS, it is saved first; if it has empty required fields, nothing is saved and a message names the column to fix. Export shows the column’s last saved settings as JSON (also as a download); Import pastes settings in, which you then save. Delete removes the column’s vLookup settings. Development mode in DFFS does not apply to vLookup: both modes use the same vLookup settings.

The child’s form

Prefilled values are written by vLookup in the child’s NewForm (in a library: EditForm, since uploads have no NewForm), so vLookup must load there:

  • If the child list uses DFFS, nothing more is needed; save a DFFS configuration for that form at least once.
  • If it does not, add the vLookup receiver: a Content Editor web part on the child’s NewForm with Content Link /SPJS/DFFS/vLookup_NewForm.html (correct the paths in the file if your SPJS library is elsewhere). It loads jQuery, SPJS-utility and SPJS-vLookup_receiver.js, which only fills in the values.

Adding children from NewForm

A new parent has no ID until it is saved, so children added from NewForm cannot link on the ID. Link them with a key that DFFS fills in instead:

  1. The parent list needs a single line of text column _DFFSID. When a form has a column with this internal name, DFFS fills it in with a timestamp (milliseconds) if it is empty.
  2. The child list needs a single line of text column to hold the parent’s key, for example ParentID. Any name works, as long as it is a single line of text column. If the child list has neither ParentID nor _vLookupParentID, the vLookup configuration offers to create ParentID.
  3. The query matches the child’s ParentID with [currentItem:_DFFSID].
  4. Prefill _DFFSID (From) into ParentID (To).
The query on ParentID with the value [currentItem:_DFFSID]
The query.
Prefill _DFFSID into ParentID
Prefilling the link.

Lists that already use _vLookupID. Earlier versions used a parent column _vLookupID and a child column _vLookupParentID for the same purpose. That pair is still supported: DFFS fills in _vLookupID the same way, so existing setups keep working. Query _vLookupParentID on [currentItem:_vLookupID] and prefill _vLookupID into _vLookupParentID. Use _DFFSID for new setups.

Labels in several languages

Labels and column headings take one text per language: click the plus sign, enter the language’s LCID (for example 1033 English, 1044 Norwegian) and the text. Always add default as a fallback for other languages.

Code: callbacks and data

Define these functions in Custom JS to react to vLookup. The fin argument is the vLookup column’s name.

FunctionCalled when
vLookupIsLoadedCallback(fin)a vLookup table has loaded or reloaded (forms only, not list views)
vlookupAddChildPreCheck(fin)the user clicks the add button; return false to stop
vlookupChildAddedCallback()a child added in a dialog was saved
vlookupChildNotAddedCallback()the add dialog was cancelled
vlookupChildViewOrEditCallback(fin, result)a child’s view or edit dialog closed; result is 1 when saved, 0 when cancelled
vLookupPresetFromUrlDone(fin)in the child’s form, a prefilled field has been set (fin is that field)
function vlookupAddChildPreCheck(fin) {
    if (fin === "vLookupTasks" && getFieldValue("Status") === "Closed") {
        spjs.dffs.alert({ "title": "Closed", "msg": "You cannot add tasks to a closed project." });
        return false;
    }
    return true;
}

The data object

spjs.vLookup.dataObj holds the data of every vLookup table that has loaded, by column name and parent item ID: the children (items), count, the columns and the totals. Tables in tabs that have not been opened are not loaded yet. Run console.log(spjs.vLookup.dataObj) in the console to look at it; spjs.vLookup.refresh("vLookupTasks") reloads one table. See the Custom JS API reference.

spjs.vLookup.dataObj in the console

Troubleshooting

Add vLookupDebug=1 to the form’s URL to see what vLookup does. Search the vLookup forum, or ask there.