API Reference¶
Every Custom Gizmo gets one global object, gizmo (also available as Gizmo), and one constant table, APIPermissions. This page lists every member with its signature, what it returns and how it behaves. The names are case-sensitive.
At a glance
- Globals
gizmo(aliasGizmo) andAPIPermissions - Data in
gizmo.Config, filled beforeOnShowruns - Data out
gizmo.Resultplusgizmo.PublishResult() - KnowledgeLake API
gizmo.API.<Group>.<Action>(body), as the signed-in user
Summary¶
| Object | What it is |
|---|---|
gizmo |
Lifecycle callbacks, inputs, results, task blocking, events and the API client |
gizmo.Config |
A PropertyBag of inputs |
gizmo.Result |
A PropertyBag of outputs |
gizmo.Events |
Events between gizmos on the task |
gizmo.API |
The KnowledgeLake REST API client |
APIPermissions |
Constants for the API permissions a gizmo can declare |
Every member, with a link to its entry:
| Member | Group | What it does |
|---|---|---|
gizmo.SetInputSchema |
Lifecycle | Declares the inputs |
gizmo.OnReceiveConfig |
Lifecycle | Runs when the configuration arrives |
gizmo.OnShow |
Lifecycle | Runs when the gizmo is visible |
gizmo.CheckIfCanProceed |
Lifecycle | Can stop the task from advancing |
gizmo.DeclarePermissions |
Lifecycle | Lists the API permissions |
gizmo.Config |
Inputs and results | PropertyBag of inputs |
gizmo.Result |
Inputs and results | PropertyBag of outputs |
gizmo.PublishResult |
Inputs and results | Sends the result to the task |
gizmo.BlockTask |
Task control | Holds the task |
gizmo.UnblockTask |
Task control | Releases the hold |
gizmo.IsViewOnlyMode |
Task control | True for a read-only task |
gizmo.Events.Publish |
Events | Sends an event |
gizmo.Events.Subscribe |
Events | Receives events |
gizmo.Events.Unsubscribe |
Events | Removes a callback |
| Typed getters and setters | PropertyBag | Read and write values by type |
| Nested bags | PropertyBag | Read and write nested PropertyBags |
schema.Add... methods |
Schema builder | Add one input each |
| Property settings | Schema builder | Label, help, default and example |
property.ConfigureUI |
Schema builder | Picks the panel control |
APIPermissions |
Permissions | Permission constants |
gizmo.API calls |
KnowledgeLake API | Calls the REST API as the user |
Lifecycle¶
graph TD
A["Save main.js in the editor"] --> B["SetInputSchema and DeclarePermissions run"]
B --> C["gizmo.json stores the schema and permissions"]
C --> D["Task page shows the gizmo: scripts load"]
D --> E["OnReceiveConfig runs and gizmo.Config is filled"]
E --> F["OnShow runs"]
F --> G["User works: set Result and PublishResult"]
G --> H["User advances: CheckIfCanProceed runs"]
H --> I["Gizmo hidden: iframe destroyed"]
I --> D
- When you save
main.js, the editor runs your gizmo and asks for its schema and permissions. It writes them togizmo.json. - When a task page shows the gizmo, the iframe loads
index.htmland your scripts. Your callbacks are registered. - The page sends the configuration. Your
OnReceiveConfigcallback runs andgizmo.Configis filled. - The page tells the gizmo it is visible. Your
OnShowcallback runs, after step 3. - The user works. You set
gizmo.Resultand callgizmo.PublishResult()as often as needed. - When the user moves to the next page or completes the task, the page calls your
CheckIfCanProceedcallback. - When the gizmo is hidden, the iframe is destroyed. Showing it again starts over at step 2.
Lifecycle callbacks¶
gizmo.SetInputSchema¶
gizmo.SetInputSchema(callback)
Declares the inputs the gizmo accepts. The editor reads it when you save main.js.
- Parameters
callback(schema), whereschemais a schema builder - Returns
gizmo, for chaining
gizmo.SetInputSchema(function (schema) {
schema.AddString("vendor-number").SetDisplayName("Vendor number");
});
gizmo.OnReceiveConfig¶
gizmo.OnReceiveConfig(callback)
Runs once the configuration arrives, and fills gizmo.Config. Required whenever you use OnShow, even if the callback is empty.
- Parameters
callback(config), whereconfigis the same PropertyBag asgizmo.Config - Returns
gizmo - Note If the callback throws,
OnShownever runs.
gizmo.OnReceiveConfig(function (config) {
// Nothing to prepare. OnShow waits for this callback.
});
gizmo.OnShow¶
gizmo.OnShow(callback)
Runs when the gizmo becomes visible, after OnReceiveConfig. Start your work here.
- Parameters
callback() - Returns
gizmo
gizmo.OnShow(function () {
document.getElementById("name").textContent = gizmo.Config.GetString("customer-name", "");
});
gizmo.CheckIfCanProceed¶
gizmo.CheckIfCanProceed(callback)
Runs when the user tries to move to the next page or complete the task. Return false to stop.
- Parameters
callback(), returning a boolean or a Promise of a boolean - Returns
gizmo
A throw lets the task proceed
If the callback throws or its Promise rejects, the task proceeds. Catch errors and return false.
gizmo.DeclarePermissions¶
gizmo.DeclarePermissions(callback)
Lists the API permissions the gizmo needs. See Permissions.
- Parameters
callback(builder) - Builder methods
builder.AddPermission(value)andbuilder.AddPermissions([values]), both chainable - Returns
gizmo
gizmo.DeclarePermissions(function (builder) {
builder.AddPermission(APIPermissions.ManageWorkitems);
});
Inputs and results¶
gizmo.Config¶
The inputs for this task, as a PropertyBag. Values are reliable only after OnReceiveConfig runs.
gizmo.Result¶
The output of the gizmo, as a PropertyBag. Set values here, then publish.
gizmo.PublishResult¶
gizmo.PublishResult()
Sends the whole Result to the task. Call it as often as you want; the latest result replaces the earlier one.
- Returns
Promise<void>that resolves when the task accepts the result - Console The browser console shows "Successfully published Gizmo result".
Task control¶
gizmo.BlockTask¶
gizmo.BlockTask()
Stops the task from moving to the next page or completing until you call UnblockTask.
- User sees "A Gizmo is preventing your Task from being advanced" (or "completed" on the last page)
- Returns Nothing
gizmo.UnblockTask¶
gizmo.UnblockTask()
Releases your block. The gizmo starts unblocked each time it loads.
- Returns: nothing
gizmo.IsViewOnlyMode¶
gizmo.IsViewOnlyMode()
Tells you whether the user opened the task read-only, for example before it is assigned. Disable input and do not block in this mode.
- Returns: boolean
Events¶
gizmo.Events.Publish¶
gizmo.Events.Publish(eventKey, data)
Sends an event to the task and to this gizmo's own subscribers.
- Parameters
eventKey(string);data(any JSON-serializable value) - Returns
gizmo.Events
gizmo.Events.Subscribe¶
gizmo.Events.Subscribe(eventKey, callback)
Calls callback with { Key, Data } for each event with that key. Use '*' to receive every event.
- Parameters
eventKey(string or'*');callback(e) - Returns
gizmo.Events - Wildcard A
'*'subscriber receives a copy whoseKeyis'*'. Put the real event name inDataif a'*'listener must tell events apart. - Repeats A handler can run more than once for one event, so make it safe to repeat.
gizmo.Events.Unsubscribe¶
gizmo.Events.Unsubscribe(eventKey, callback)
Removes a callback. Pass the same function you subscribed.
- Returns:
gizmo.Events
Unsubscribe removes more than one callback
It also removes every callback subscribed after it for that key. Subscribe once and keep the subscription.
PropertyBag¶
gizmo.Config and gizmo.Result are PropertyBags.
- Typed storage A PropertyBag stores each type separately. A value set with
SetIntis not returned byGetString. - Missing key A getter returns
default(ornull). - Chaining A setter returns the bag, so calls chain.
Typed values¶
| Type | Read | Write | Note |
|---|---|---|---|
| String | GetString(key, default) |
SetString(key, value) |
Task inputs always arrive as strings. |
| String array | GetStringArray(key, default) |
SetStringArray(key, value) |
GetStringArray parses a JSON string. |
| Integer | GetInt(key, default) |
SetInt(key, value) |
|
| Integer array | GetIntArray(key, default) |
SetIntArray(key, value) |
|
| Long integer | GetLong(key, default) |
SetLong(key, value) |
|
| Decimal | GetDecimal(key, default) |
SetDecimal(key, value) |
|
| Boolean | GetBoolean(key, default) |
SetBoolean(key, value) |
|
| Date | GetDateTime(key, default) |
SetDateTime(key, value) |
Stored as a string. |
| Byte array | GetByteArray(key, default) |
SetByteArray(key, value) |
var vendor = gizmo.Config.GetString("vendor-number", "");
gizmo.Result.SetString("vendor-status", "approved").SetBoolean("checked", true);
Nested bags¶
| Method | What it does |
|---|---|
GetPropertyBag(key, default) |
Reads a nested PropertyBag |
SetPropertyBag(key, callback) |
Builds a nested PropertyBag with callback(bag) |
GetPropertyBagArray(key, default) |
Reads an array of PropertyBags |
SetPropertyBagArray(key, bags) |
Writes an array of PropertyBags |
SetPropertyBagArrayCallback(key, length, callback) |
Builds an array of length bags. callback(bag, index) fills each one. |
SetPropertyBagArrayCallbackAsync(key, length, callback) |
The async version. callback(bag, index) returns a Promise. Returns a Promise. |
Schema builder¶
SetInputSchema passes a schema builder.
- Add calls Each
Add...call takes a key and returns a property you configure by chaining. - addToFront Optional boolean. It puts the property first in the list.
Add methods¶
| Method | Adds | Read it with |
|---|---|---|
schema.AddString(key, addToFront) |
A string input. Prefer it for inputs aliased to task inputs. | GetString |
schema.AddStringArray(key, addToFront) |
A string array input | GetStringArray |
schema.AddInt(key, addToFront) |
An integer input | GetInt |
schema.AddLong(key, addToFront) |
A long integer input | GetLong |
schema.AddDecimal(key, addToFront) |
A decimal input | GetDecimal |
schema.AddBool(key, addToFront) |
A boolean input | GetBoolean |
schema.AddDateTime(key, addToFront) |
A date input | GetDateTime |
schema.AddByteArray(key, addToFront) |
A byte array input | GetByteArray |
schema.AddPropertyBag(key) |
A nested group. Returns a nested schema builder. | GetPropertyBag |
Property settings¶
| Method | What it sets |
|---|---|
property.SetDisplayName(name) |
The label in the Configure Gizmo panel |
property.SetDescription(text) |
The help text in the panel |
property.SetDefaultValue(value) |
The value used when the layout does not set one |
property.SetExampleValue(value) |
An example shown to the layout designer |
property.ConfigureUI(callback) |
The control in the panel |
schema.AddString("vendor-number")
.SetDisplayName("Vendor number")
.SetDescription("The vendor to look up")
.SetDefaultValue("")
.SetExampleValue("V-10442");
property.ConfigureUI¶
property.ConfigureUI(callback)
Picks the control in the Configure Gizmo panel. callback(ui) calls one of these:
| Call | Extra options |
|---|---|
ui.AsTextbox() |
AllowMultipleLines(), SetNumberOfLines(n) |
ui.AsDropDown() |
AddOption(displayText, value), AllowFillIns(bool), AllowNone(bool) |
ui.AsCheckbox() |
none |
ui.AsCurrency() |
SetNumberOfDecimals(n) |
ui.AsDateTime() |
AsDateOnly() |
ui.AsNumber() |
SetNumberOfDecimals(n) |
ui.AsRadioButtonGroup() |
AddOption(displayText, value), AllowNone(bool), AllowFillIns(bool) |
ui.AsCheckBoxGroup() |
AddOption(displayText, value), AllowNone(bool), AllowFillIns(bool) |
Every control also has SetVisibility(bool), Disable(), SetLabelText(text) and SetCulture(culture).
gizmo.SetInputSchema(function (schema) {
schema.AddString("review-mode")
.SetDisplayName("Review mode")
.SetDefaultValue("standard")
.ConfigureUI(function (ui) {
ui.AsDropDown()
.AddOption("Standard", "standard")
.AddOption("Strict", "strict")
.AllowNone(false);
});
});
Inputs from the task¶
Each schema key can be set in the layout or passed in as a task input.
- In Configure Gizmo, tick Use Value from Input.
- Give an Input Name (no periods).
Task inputs arrive as text, so prefer AddString for aliased inputs and convert in your code.
Permissions¶
How declared permissions gate the gizmo:
- When you save
main.js, the list goes intogizmo.json. - When you add the gizmo to a layout, the layout copies the list. Select Custom Gizmo shows it as Required Permissions.
- When a user opens a task page, the page checks that the user has every permission declared by every gizmo on the page. If one is missing, the page does not load and the user sees: You are missing the "..." permission required by the ... Gizmo.
- Each
gizmo.APIcall is still checked on the server against the signed-in user. Declaring a permission does not grant it.
Every task user also needs Use Custom Gizmos to load any custom gizmo.
APIPermissions values¶
| Constant | Feature key and what it unlocks |
|---|---|
BatchRead |
openapi_api_ft_batch_read: read work items, including V1_ProcessingAPI.QueryForWorkItems and QueryForWorkItemHistories |
BatchLock |
openapi_api_ft_batch_lock |
BatchEdit |
openapi_api_ft_batch_edit |
ManageWorkitems |
openapi_api_ft_manage_workitems: V1_KWorkItemAPI |
ManageWorkflows |
openapi_api_ft_manage_workflows: V1_WorkflowAPI |
ManageTriggers |
openapi_api_ft_manage_triggers |
ManageFingerprints |
openapi_api_ft_manage_fingerprints: V1_IntuitiveAIAPI and the legacy V1_LearnAPI |
ManageSendemails |
openapi_api_ft_manage_sendemails |
Repository |
openapi_api_ft_repository |
RepositoryDownloaddocuments |
openapi_api_ft_repository_downloaddocuments |
RepositoryRunsearches |
openapi_api_ft_repository_runsearches |
Editdocuments |
openapi_api_ft_editdocuments |
RecycleDocuments |
openapi_api_ft_recycle_documents |
CatalogsView |
openapi_api_ft_catalogs_view: V1_AppsAPI catalogs, users and groups |
Processes |
openapi_api_ft_processes |
EventsWrite |
openapi_api_ft_events_write |
InteractionAdd |
openapi_api_ft_interaction_add |
InteractiondefList |
openapi_api_ft_interactiondef_list |
JobsGet |
openapi_api_ft_jobs_get: V1_JobsAPI.QueryForJobRuns and QueryForJobHistories |
JobsManage |
openapi_api_ft_jobs_manage: V1_JobsAPI.ResubmitJob |
BotsGet |
openapi_api_ft_bots_get: V1_AutomationAPI.GetBots and V1_RPAAPI.QueryForLatestRPATasks |
BotsManage |
openapi_api_ft_bots_manage: V1_RPAAPI.ResubmitRPATask |
GatewaysGet |
openapi_api_ft_gateways_get: V1_RepositoryAPI.GetRemoteGateways |
Secret global variables
There is no constant for the Manage Secret Global Variables feature. V1_WorkflowAPI.SetSecretGlobalVariable checks it on the server, in addition to ManageWorkflows.
Calling the KnowledgeLake API¶
gizmo.API calls¶
gizmo.API.<Group>.<Action>(body)
Calls one action of the public REST API as the signed-in user. The call goes through the task page; the gizmo never sees a token.
- Parameters
body(object), the same request body as the REST API. Actions with no body take no argument. - Returns A Promise of the standard envelope
{ Success, MessageKey, Data } - Failures A failed call can reject the Promise or resolve with
Success: false. Handle both. - Unknown names A group or action that does not exist rejects with "Invalid Controller" or "Invalid Endpoint".
gizmo.API.V1_KWorkItemAPI.GetWorkItem({ WorkItemId: workItemId })
.then(function (response) {
if (!response || !response.Success) {
throw new Error("GetWorkItem failed: " + (response ? response.MessageKey : "no response"));
}
var workItem = response.Data; // { WorkItemId, Name, Documents, Metadata }
})
.catch(function (err) {
console.error("API call failed", err);
});
API groups¶
gizmo.API mirrors the published API spec, so it has every group a tenant publishes:
| Group | Typical use from a gizmo |
|---|---|
V1_AppsAPI |
Catalogs, users (with their tokens) and groups |
V1_KWorkItemAPI |
Read and change the current work item, its documents and metadata |
V1_BatchAPI |
Work item operations that use the older batch name |
V1_RepositoryAPI |
Content types, saved searches, documents in a destination |
V1_ProcessingAPI |
QueryForWorkItems and QueryForWorkItemHistories for monitor data |
V1_WorkflowAPI |
Workflows and global variables |
V1_JobsAPI |
Scheduled job runs and history; run a job now |
V1_RPAAPI |
Latest RPA task attempts; rerun a task |
V1_AutomationAPI |
Bots |
V1_IntuitiveAIAPI |
Intuitive AI classes and extraction hints |
V1_TriggerAPI, V1_EventsAPI |
Triggers; write events |
Common calls¶
The request and response shapes are on the REST API pages. Common calls from gizmos:
| Call | Body and permission |
|---|---|
V1_KWorkItemAPI.GetWorkItem |
{ WorkItemId }. ManageWorkitems. |
V1_AppsAPI.GetCatalogs |
none. CatalogsView. |
V1_AppsAPI.GetUsers |
{ CatalogId }. CatalogsView. Returns users with Token, DisplayName, Email. |
V1_ProcessingAPI.QueryForWorkItems |
{ WorkitemName, Status, PageSize } (all optional). BatchRead. |
V1_JobsAPI.QueryForJobRuns |
{ JobStatus, PageSize } (all optional). JobsGet. |
gizmo.API.V1_ProcessingAPI.QueryForWorkItems({ WorkitemName: workItemName, PageSize: 50 })
.then(function (response) {
var others = (response && response.Success ? response.Data : []).filter(function (w) {
return String(w.WorkItemId).toLowerCase() !== String(workItemId).toLowerCase();
});
showDuplicates(others); // each has WorkItemId, WorkItemName, Status, Process, Step
});
- WorkitemName Matches the whole name, case-insensitive.
- Visibility Only work items in workflows the user can view are returned.
A gizmo learns its work item id through a task input. See Show Work Item Data with gizmo.API.
Related¶
- Getting Started
- Security and Sandboxing
- API Introduction
- API Authentication (for calls from outside a gizmo)