Home Reference Source
import SdkLifecycle from './gui/core/SdkLifecycle.jsx'
public class | source

SdkLifecycle

SDK Lifecycle provides two lifecycle methods SetConfiguration and GetConfiguration.

Static Member Summary

Static Public Members
public static

The purpose of GetConfiguration is for Alteryx to get your tool’s configuration from the UI to store in the workflow.

public static

SetConfiguration will be given the current tools XML configuration as the first and only parameter.

Static Public Members

public static GetConfiguration: * source

The purpose of GetConfiguration is for Alteryx to get your tool’s configuration from the UI to store in the workflow. This function will be executed as the last thing the browser in the tool configuration pane does before closing. Any time you change tools, or click out of the tool pane in general (for instance, to run the workflow), this will be executed. The way it passes the configuration object to Alteryx is by executing the window.Alteryx.JsEvent function, with a stringified object of the given structure:

window.Alteryx.JsEvent(JSON.stringify({ Event: 'GetConfiguration', Configuration: { Configuration: {...toolsConfigObject...} } }))

By giving this parameter to the window.Alteryx.JsEvent function, Alteryx will again use JSON.Net to convert the JSON object in the Configuration.Configuration property described above into the XML which will be persisted in the workflow.

public static SetConfiguration(args: object): * source

SetConfiguration will be given the current tools XML configuration as the first and only parameter. It’s executed when you click on the tool. Specifically, it executes first thing when the tool configuration pane loading your tool’s configuration UI page has signaled it is no longer loading the HTML page. The object handed to this function is in fact a JavaScript object with the current tool configuration as well as other relevant information for the tool developer, including upstream fields available to the tool, the tool ID, and whether or not it is presently in a macro. The full structure of this object is detailed below. The tool’s configuration is in a property named Configuration which is an object constructed by using NewtonSoft Json.Net’s JsonConvert.SerializeObject function on the System.Xml.XmlElement object containing the current tools configuration.

For details on how this will turn your tool XML configuration into JSON, you may reference the source here: https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs The JSON.Net documentation is here: http://www.newtonsoft.com/json/help/html/ConvertingJSONandXML.htm

Once the reading of the tool’s configuration into the page’s UI controls is complete, at the end of the SetConfiguration function, there must be a call to notify Alteryx that the configuration has finished loading correctly. This call will be done by executing the window.Alteryx.JsEvent function with a JSON stringified object {Event: 'SetConfiguration'}