Functions
API
Make a Fulcrum REST API call
Parameters
path
String (required) - API path
options
Object - API request options
Returns
String
Examples
API('/choice_lists', {qs: {per_page: 1}})
AUDIOURL
Generate a public audio URL
Parameters
id
String (required) - The ID of the audio file
options
Object - {version: 'original', expires: null}
Returns
String
Examples
AUDIOURL($my_audio_field[0].audio_id, {version: 'original'})
FORMATDATE
Format date
Parameters
date
Date (required) - The date to be formatted
options
Object - Intl.DateTimeFormat options
Returns
String
Examples
FORMATDATE(new Date())
GET
Simple HTTP GET, synchronous
Parameters
url
String (required) - Request URL
options
Object - Request options
Returns
String
Examples
GET('https://jsonplaceholder.typicode.com/posts', {qs: {userId: 1}})
GETBLOB
Simple HTTP GET, returns ArrayBuffer, synchronous
Parameters
url
String (required) - Request URL
options
Object
Returns
String
Examples
GETBLOB('https://learn.fulcrumapp.com/img/branding/fulcrum-icon.png')
JSONREQUEST
Similar to GET but auto parses JSON
Parameters
options
Object - Request options
Returns
String
Examples
JSONREQUEST({url: 'https://jsonplaceholder.typicode.com/posts', qs: {userId: 1}})
LOG
Log something, appears in the output of reports for debugging
Parameters
string
String (required) - The thing to log
Returns
String
Examples
LOG('Hello World')
PHOTOURL
Generate a public photo URL
Parameters
id
String (required) - The ID of the photo
options
Object - {version: 'large', expires: null}
Returns
String
Examples
PHOTOURL($my_photo_field[0].photo_id, {version: 'thumb'})
QS
Generate a query string from an object (no need to string concat)
Parameters
object
Object (required) - The parts of the query string
Returns
String
Examples
QS({name: "Robert", age: "20"}
// name=Robert&age=20
QUERY
Run a SQL query on the Query API
Parameters
sql
String (required) - SQL query
options
Object
Returns
String
Examples
QUERY('SELECT name FROM forms', {format: 'json'})
QUERYVALUE
Run a SQL query on the Query API and return the first column of the first row (or null). Simple helper for returning scalar values.
Parameters
sql
String (required) - SQL query
Returns
String
Examples
QUERYVALUE(`SELECT form_id FROM forms WHERE name = '${form.name}'`)
RENDERVALUES
Recurse the form values to render dynamic reports
Parameters
feature
Number (required) - The number of which to return the absolute value.
options
Object - Rendering options ({recurseSections: true, recurseRepeatables: true}
).
eachFunction
Function(element, value) (required) - The render function for each element.
Returns
JSON - the feature elements
and values
Examples
<% RENDERVALUES(record, null, function(element, value) { %>
<% if (element.isSectionElement) { %>
<h1 class="field-section"><%= element.label %></h1>
<% } else if (element.isRepeatableElement) { %>
<% if (value.length) { %>
<h1 class='field-section'><%= element.label %> <%= value && `(${value.displayValue})` %></h1>
<% } else { %>
<h1 class="field-section"><%= value && value.displayValue %></h1>
<% } %>
<% } else if (element.isPhotoElement) { %>
<div class="field">
<h2 class="field-label"><%= element.label %></h2>
<div class="field-value">
<% value && value.items.forEach((item, index) => { %>
<img class="photo" src="<%= PHOTOURL(item.mediaID) %>" />
<% if (item.caption) { %>
<p><%= item.caption %></p>
<% } %>
<% }); %>
</div>
</div>
<% } else if (element.isSignatureElement) { %>
<div class="field">
<h2 class="field-label"><%= element.label %></h2>
<% if (value && !value.isEmpty) { %>
<div class="field-value">
<img class="signature" src="<%= SIGNATUREURL(value.id) %>" />
<% if (value.timestamp) { %>
<p><%= element.agreementText %></p>
<p>Signed <%= FORMATDATE(value.timestamp) %></p>
<% } %>
</div>
<% } %>
</div>
<% } else if (element.isRecordLinkElement) { %>
<div class="field">
<h2 class="field-label"><%= element.label %></h2>
<% if (value && !value.isEmpty) { %>
<div class="field-value"><%= value.items.map(item => item.displayValue).join(', ') %></div>
<% } %>
</div>
<% } else { %>
<div class="field">
<h2 class="field-label"><%= element.label %></h2>
<div class="field-value pre"><%= value && value.displayValue %></div>
</div>
<% } %>
<% }) %>
SIGNATUREURL
Generate a public signature URL
Parameters
id
String (required) - The ID of the signature file
options
Object - {version: 'original', expires: null}
Returns
String
Examples
SIGNATUREURL($my_signature_field.signature_id, {version: 'original'})
STATICMAP
Generate a Google or Esri Static Map based on the value of the report template’s Map Engine.
Parameters
options
object (required) - Google Static Maps API options {center, zoom, size, scale, format, maptype, markers, path}
To change the map engine in the STATICMAP function directly, update the options passed into the parameters of the STATICMAP function:
<%= STATICMAP({mapEngine: ‘esri’, markers, ...SET_MAP_OPTIONS()}) %>
Returns
String
Examples
STATICMAP({mapEngine: ‘google’,markers: '34.052230,-118.243680', maptype: 'hybrid', size: '300x300'})
<img src='<%= STATICMAP({mapEngine: ‘esri’, ...SET_MAP_OPTIONS()}) %>' />
<img src="<%= STATICMAP({markers: '34.052230,-118.243680', maptype: 'hybrid', size: '300x300'}) %>" />
TOJSON
JSON.stringify helper
Parameters
json
JSON object (required)
Returns
String
Examples
TOJSON(API('/choice_lists').choice_lists[0].name)
VIDEOURL
Generate a public video URL
Parameters
id
String (required) - The ID of the video file
options
Object - {version: 'original', expires: null}
Returns
String
Examples
VIDEOURL($my_video_field[0].video_id, {version: 'original'})
Updated 5 months ago