Lifecycle Methods
The HTML SDK provides five lifecycle methods that can be used in a variety of patterns to create tools.
Lifecycle methods
The lifecycle methods load in the following order:
- SetConfiguration: Executed when the tool is clicked on. Used to obtain the tool's configuration as soon as the tool finishes loading the HTML.
- BeforeLoad: Executed before the data stores are loaded. Used to manually configure data stores.
- calls the window.Alteryx.Gui.Annotation function, which provides a workflow canvas annotation for your tool by returning a string.
- interacts with the HTML GUI SDK widgets.
- provides an easy API for accessing upstream field and tool information.
- AfterLoad: Executed after the data stores have been loaded. Used to trigger application logic. Retrieves values from data items after the manager has loaded values from the incoming XML configuration.
- calls the window.Alteryx.Gui.Annotation function, which provides a workflow canvas annotation for your tool by returning a string.
- interacts with the HTML GUI SDK widgets.
- provides an easy API for accessing upstream field and tool information.
- BeforeGetConfiguration: Executed before the GetConfiguration event is fired. Allows for current configuration data to be changed before obtaining the tool configuration on deselection. Used to change the values or the structure of the persisted data.
- GetConfiguration: Executes as the final action before a tool is deselected, obtains the tool configuration from the GUI.
SetConfiguration: function (currentToolConfiguration){...}

currentToolConfiguration: The tool's configuration from the property Configuration. Configuration is constructured by converting system.Xml.XmlElement to JSON using the JsonConvert.SerializeObject method from NewstonSoft Json.Net. See Json.NET documentation. See converter source file.
window.Alteryx.Gui.BeforeLoad = function (manager, AlteryxDataItems, json) {...}

manager: An object that implements the SetConfiguration and GetConfiguration functions, managing data items, their content from the configuration, and their persistance in the workflow. The manager also:
The manager’s full API is detailed in the API reference documentation.
AlteryxDataItems: An object with various data item type constructors on it, so you may new them up from it. For the full listing of supported data items, see Supported Data Items.
new AlteryxDataItems.SimpleInt('X')
json: An object containing the actual JSON that provides the tool’s current configuration data. The actual persisted XML configuration data is under the Configuration property. The short object description is:
{
MacroMode: bool,
IsFirstConfig: bool,
IsNoConfig: bool,
Configuration: object,
MetaInfo: array of object,
ToolId: int,
ToolName: string
}
window.Alteryx.Gui.AfterLoad = function (manager, AlteryxDataItems) {...}

manager: An object that implements the SetConfiguration and GetConfiguration functions, managing data items, their content from the configuration, and their persistance in the workflow.
The manager also:
The manager’s full API is detailed in the API reference documentation.
AlteryxDataItems: An object with various data item type constructors on it, so you may new them up from it. For the full listing of supported data items, see Supported Data Items.
new AlteryxDataItems.SimpleInt('X')
window.Alteryx.Gui.BeforeGetConfiguration = function (json) {...}

json: An object containing the actual JSON that provides the tool’s current configuration data. The actual persisted XML configuration data is under the Configuration property. The short object description is:
{
MacroMode: bool,
IsFirstConfig: bool,
IsNoConfig: bool,
Configuration: object,
MetaInfo: array of object,
ToolId: int,
ToolName: string
}
GetConfiguration: function () {...}
UI creation patterns
There are several methods available to creating a tool. Evaluate what your users require of your tool before determining what method of creation you want to use.
If the tool is filling in an existing UI, it does not need to persist configuration between uses. If the tool has configuration settings that persist, but are not displayed to a user, the tool does not need to synchronize data between UI controls and the configuration persistence.
UI creation pattern | Tool automatically loads and persists your configuration | Tool automatically synchronizes data between UI controls and configuration persistence |
---|---|---|
Use only SetConfiguration and GetConfiguration | No | No |
Use BeforeLoad and AfterLoad with Data Items | Yes | No |
Using data items with widgets | Yes | Yes |