Interface Builder JS Functions
Built-in JavaScript functions for the Interface Builder's Code tab, talk to Tables, Workflows, and more.
The Interface Builder's Code tab runs custom JavaScript inside a widget iframe. Rayven injects a set of global helper functions into that iframe so custom code can read/write Table data, pull data from a Workflow's API Node, navigate between interfaces, and read user context, without hand-rolling HTTP calls. These are browser-side, camelCase, callback-style functions.
Functions that fetch data are asynchronous: pass a callback function name (as a string), and Rayven invokes that global function with the result once it's ready, rather than returning a value directly. The two exceptions are getPublicLinkForQR() and getPrivateLinkForQR(), which return a Promise.
Don't confuse these with the Workflow JavaScript Node functions. A Workflow's JavaScript Node has its own set of similarly-purposed but differently-named helper functions, documented separately on the Logic Nodes Reference page. Those are server-side, PascalCase, and synchronous (no await), for example, getDataFromTable here vs. GetDataFromTable there. The naming is close enough to cause copy-paste bugs, so double-check which context you're writing code for before reusing a snippet.
Sending data to a Workflow or device
pushPayload(payload, nodeId, type = "default", typeValue = "", timestamp = -1)
Sends a JSON payload to the Push from Interface node identified by nodeId, with routing rules deciding which UID(s) at that node receive it. type can be:
"default", the app's default UID,record1"UID", one specific UID, given intypeValue"labelName", every UID with a non-empty value in that label column"labelValue", every UID matching aname=valuelabel pair intypeValue, e.g."state=Israel"
pushPayload({ mode: "eco" }, 205813, "UID", "record1", Date.now());
pushPayload({ alert: true }, 205813, "labelName", "state");
pushPayload({ threshold: 42 }, 205813, "labelValue", "state=israel");
savePayload(json, timestamp = -1)
Sends a JSON payload to IoTX for the current node only, not the whole flow connected to the node. UIDs are resolved from the widget's current view/label context, not an explicit routing rule.
savePayload({ command: "restart" }, Date.now());
Reading and writing Table data
getDataFromTable(tableName, returnFunction, lookupFieldName, filterFieldByValue, rowCount)
Queries a Primary or Secondary Table and hands matching rows to a callback. Call with just tableName and returnFunction to fetch all rows.
function showTableData(data) { console.log("Table Data:", data); }
getDataFromTable("Your Table Name", "showTableData", "username", "status=active", 50);
insertDataToTable(tableName, returnFunction, jsonData)
Inserts a new row, enforcing the table's normal rules (permissions, key/required/unique columns, linked-UID/label validation).
insertDataToTable("Users", "onInsertResult", JSON.stringify({ username: "john_doe", status: "active", role: "admin" }));
updateDataToTable(tableName, returnFunction, jsonData)
Updates ONE existing row, matched by the table's key column. jsonData must include the key field plus the changed fields. Subject to the same validation as insert.
updateDataToTable("Users", "onUpdateResult", JSON.stringify({ username: "john_doe", status: "inactive", role: "viewer" }));
deleteDataTableRow(tableName, returnFunction, jsonData)
Deletes ONE row, matched by the key field in jsonData. The default UID row (record1) cannot be deleted.
deleteDataTableRow("Users", "onDeleteResult", JSON.stringify({ username: "john_doe" }));
All four Table functions return their result via the named callback as { "status": "success", "status_description": "..." } on success, or { "status": "fail", "status_description": "..." } (e.g. unique-column violation, missing key field) on failure.
Reading data from a Workflow's API Node
getDataFromAPINode(nodeId, returnFunction, startDate, endDate, latestByUID, filterType, filterValues)
Fetches data from a workflow's API/Push to Interface node, optionally scoped to a date range, passing the result to a callback as { status, status_description, objects: [...] }. The widget's current Drill-Down context (UID or label) applies automatically where supported; pass explicit filters for something different: filterType="uids", filterValues="ABC123,DEF456" for specific device codes, or filterType="labels", filterValues="Lobby,Floor 3" for label matches (requires the API node's tag grouping to be "ByTagName").
function processData(result) { console.log("API Data:", result); }
getDataFromAPINode(55, "processData", "2025-01-01 00:00:00", "2025-01-07 23:59:59");
getDataFromAPINode(55, "processData", "", "", true); // latest value per UID
getDataFromAPINode(55, "processData", "", "", false, "uids", "ABC123, DEF456");
Navigating and controlling the interface
linkToInterface(dashboardName, filterType, filterValue)
dashboardName is given as "viewId,viewName" (typing @ in the field opens a picker of views). Navigation is Drill-Down aware by default, it carries over whatever UID/label context the current widget is in. Explicit modes override this: "label" forces a specific label value (only valid on label-grouped widgets); "uid" forces navigation to a specific device code, ignoring label context.
linkToInterface("101,Main Dashboard");
linkToInterface("101,Main Dashboard", "label", "Australia");
linkToInterface("101,Main Dashboard", "uid", "ABC123");
refresh()
Manually re-fetches the widget's data.
pauseRefresh()
Pauses the widget's automatic refresh cycle.
unpauseRefresh()
Resumes the widget's automatic refresh cycle.
clickViewTab(viewName)
Activates a view tab by its visible name.
clickViewTab("Statistics");
Widget-local data store
setHTMLNodeGData(key, value)
Stores a value in a shared, in-session HTMLNodeGData object, a simple way to pass a value between widgets on the same interface session without round-tripping through a Table.
getHTMLNodeGData(key)
Retrieves a value previously stored with setHTMLNodeGData. Returns null if the key was never set.
setHTMLNodeGData("theme", "dark");
let theme = getHTMLNodeGData("theme"); // "dark"
Other utilities
getUserDetails(returnFunction)
Fetches the logged-in App User's details (name, email, phone, permission level, timezone) and their User Group's details (name, permission level, timezone, group type), plus any master-tag filters assigned at the user or group level.
getUserDetails("onUserDetailsLoaded");
function onUserDetailsLoaded(result) { console.log("User Details:", result); }
getPublicLinkForQR()
Returns a Promise<String> resolving to a direct-access URL for the current interface, suitable for embedding in a QR code. The public link is openly accessible.
getPublicLinkForQR().then(url => console.log("Public Link:", url));
getPrivateLinkForQR()
Returns a Promise<String> resolving to a direct-access URL for the current interface, suitable for embedding in a QR code. The private link skips tabs/login-code but still requires whatever auth context it's opened with.
readListingsFromFTP(path, returnFunction)
Reads a file/directory listing from an FTP location configured under App Settings, and passes it to a callback. Use an empty string for the root folder.
readListingsFromFTP("reports", "handleFTPResponse");
Frequently Asked Questions
Why doesn't getDataFromTable() just return my data directly?
These are asynchronous, callback-based functions, not Promises. Pass the name of a global function (as a string) as the returnFunction argument, and Rayven calls it with the result once the data is ready, your code can't just assign the return value to a variable.
Is getDataFromTable the same as GetDataFromTable in a workflow?
No, they're separate functions that happen to share a name. getDataFromTable (camelCase) runs in the Interface Builder's Code tab, is browser-side, and is callback-based. GetDataFromTable (PascalCase) runs in a Workflow's JavaScript Node, is server-side, and returns its result directly (no await needed). The parameter lists even look similar, so copy-pasting a snippet between the two contexts is a common source of bugs, check which one you're in before reusing code.
What's the difference between pushPayload() and savePayload()?
pushPayload() sends JSON to a specific Push from Interface node (given by nodeId), using explicit routing rules (type and typeValue) that decide which UID(s) at that node receive it. savePayload() sends to IoTX for the current node only, with UIDs resolved from the widget's current view/label context rather than a routing rule you specify.
Why does my linkToInterface() call jump to the wrong device or label?
By default, linkToInterface() is Drill-Down aware and carries over the current widget's UID/label context. If you need to force a different target, pass an explicit mode: "label" to force a label value, or "uid" to force a specific device code, overriding whatever context the widget is currently in.
Can I share data between two widgets without writing to a Table?
Yes, use setHTMLNodeGData(key, value) and getHTMLNodeGData(key) to pass a value between widgets on the same interface session. It's in-memory and session-local, so don't rely on it for anything that needs to persist, use a Table for that.
Where do I find the server-side Workflow equivalents of these functions?
See the JavaScript Node entry on the Logic Nodes Reference for the PascalCase, synchronous helper functions used inside a Workflow, as opposed to the camelCase, callback-based functions on this page.
Which Workflow node's data can I read with getDataFromAPINode()?
The Push to Interface node. See the Logic Nodes Reference for how to configure that node, and Core Concepts for why it stores data in Cassandra rather than a Table.
How do I persist data across sessions instead of just in memory?
Write it to a Table using getDataFromTable() to read and a Workflow's Update Tables node to write, rather than relying on the session-local setHTMLNodeGData()/getHTMLNodeGData() pair.
Related articles
For more on how these functions fit into the wider platform, see: