Lifecycle Methods

Version:
Current
Last modified: June 11, 2020

Lifecycle Methods

The HTML SDK provides five lifecycle methods that can be used in a variety of patterns to create tools. The lifecycle methods load in this 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.
HTML
  1. SetConfiguration: function (currentToolConfiguration){...}

Parameters

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.

 

  • BeforeLoad: Executed before the data stores are loaded. Used to manually configure data stores.
XML
  1. window.Alteryx.Gui.BeforeLoad = function (manager, AlteryxDataItems, json) {...}

Parameters

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:

  • 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.

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.

HTML
  1. 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:

XML
  1. {
  2. 	MacroMode: bool,
  3. 	IsFirstConfig: bool,
  4. 	IsNoConfig: bool,
  5. 	Configuration: object,
  6. 	MetaInfo: array of object,
  7. 	ToolId: int,
  8. 	ToolName: string
  9. }
  • 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.
XML
  1. window.Alteryx.Gui.AfterLoad = function (manager, AlteryxDataItems) {...}

Parameters

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...

  • 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.

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.

XML
  1. 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:

XML
  1. {
  2. 	MacroMode: bool,
  3. 	IsFirstConfig: bool,
  4. 	IsNoConfig: bool,
  5. 	Configuration: object,
  6. 	MetaInfo: array of object,
  7. 	ToolId: int,
  8. 	ToolName: string
  9. }
  • 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.
XML
  1. window.Alteryx.Gui.AfterLoad = function (manager, AlteryxDataItems) {...}

Parameters

HTML
  1. new AlteryxDataItems.SimpleInt('X')
  • 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.
XML
  1. window.Alteryx.Gui.BeforeGetConfiguration = function (json) {...}

Parameters

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:

XML
  1. {
  2. 	MacroMode: bool,
  3. 	IsFirstConfig: bool,
  4. 	IsNoConfig: bool,
  5. 	Configuration: object,
  6. 	MetaInfo: array of object,
  7. 	ToolId: int,
  8. 	ToolName: string
  9. }
  • GetConfiguration: Executes as the final action before a tool is deselected, obtains the tool configuration from the GUI.
XML
  1. 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
Was This Helpful?

Running into problems or issues with your Alteryx product? Visit the Alteryx Community or contact support.