Applications and Applets
Widgets
Widget Code Structure
8 min
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 https //lit element polymer project org/guide/properties 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 https //lit element polymer project org/guide/lifecycle#requestupdate documentation of litelement lifecycle methods and properties can be found here https //lit element polymer project org/guide/lifecycle 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 https //lit element polymer project org/guide/events 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 id s 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