Widget Code Structure
ο»ΏThe widget is implemented as an anonymous class which extends the HTMLElement class. The preferred method to create a widget is to extend the SwimlaneElement which extends the LitElement class which itself extends HTMLElement class.
Here is an example of the default widget with annotation added:
Properties
SwimlaneElement defines the following properties:
- this.record - Available to record widgets, an object containing key-value pairs for each field on the record.
- this.report - Available to report widgets, an object containing data, rawData, and query.
- this.contextData - Available to both record and report widgets, an object containing data such as application, currentUser, origin, and token.
Documentation on how LitElement handles properties and attributes can be found here.
Lifecycle
In addition to the HtmlElement and LitElement lifecycle methods, SwimlaneElement adds the resizedCallback method.
- resizedCallback - This method (called whenever the element is resized) but default simply calls requestUpdate.
Documentation of LitElement lifecycle methods and properties can be found here.
Events
SwimlaneElement adds the following methods for emitting Swimlane widget events:
- this.updateRecordValue(key, value) : Available to record widgets. Updates record data by field key.
- this.addComment(key, value) : Available to record widgets. Adds a new comment by field key.
- this.triggerIntegration(taskId) : Available to record widgets. Triggers an integration.
- this.triggerSave() : Available to record widgets. Triggers record save on the record page.
Documentation on how to handle events in LitElement can be found here.
For single value fields (text/numeric/date fields, etc) or single-select fields types simply emit the new value:
For text and numeric list field types, emit an array of new values. If duplicate values exist, their ids get reused.
For multi-select field types (selects, radio buttons, checkboxes), emit an array of new values. Every element in the value must exist in the contextData.
To add a comment emit the new comment as a string.