Environment Methods

Environment Methods

There are two different types of script environments available in the addon system. There is the Form Script Environment, which is used for addons that require a user interface consisting of forms and form elements, and the System Script Environment, which is used for addons that are meant to be executed by services or run silently without user interaction in a form-based application. The two different types of script environments each have their own set of methods that are available for use by addon scripts, in addition to several methods that are common to all script environments. Below, you will find links to a list of methods available for each script environment type, as well as a list that represents the methods that are available to all script environments.

Common Environment Methods

This section details the list of methods that are common to all script environments.

  • CreateDatabaseConnection(string connectionFileName): Creates an external database connection that can be used to query a data source.

  • CreateManagedDatabaseConnection(): Creates a managed database connection that allows access to the database used by the host application.

  • ExecuteCommand(string commandName, object args): Executes a form command supported by the current form using the provided args. The args parameter can be either a single value or a Lua table of values (ie: {"Detail", 0, ...}).

  • GetFieldValue(string fieldSource, string fieldName): Retrieves the value of a field (fieldName) on a data source (fieldSource) exposed by the current form.

  • GetSetting(string settingName): Retrieves the value of the specified setting from the addon settings. The setting value will automatically be converted to the correct type based on the type specified in the setting's definition.

  • GetStaticValue(string name): Retrieves the value of the specified static value from the internal static value storage collection.

  • LogDebug(string message): Writes the message to the debug log.

  • Print(DataTable table, string dataSource, string templateDocuments): Prints data from an addon provided table using the provided data source and template documents.

  • SetFieldValue(string fieldSource, string fieldName, object value): Sets the value of a field (fieldName) on a data source (fieldSource) exposed by the current form to the given value.

Form Script Environment Methods

The Form Script Environment is used for addons that have a Type of "Addon".

  • GetClientImage(string Name): Retrieves an Image object corresponding to the name provided from the application resources file.

  • GetInterfaceManager(): Retrieves the ScriptInterfaceManager associated with the current script.

  • GetLocalImage(string path): Retrieves an Image object based on the file provided by the path argument. The path can be either rooted or relative to the script file's location.

System Script Environment Methods

The System Script Environment is used for addons that have a type of "System" or "Server", with the exception of the ProcessDataContexts method, which can only be used with server addons. 

  • ProcessDataContexts(string contextIDType, object contextIDs, string methodName): Initiates iterative processing of a list of data contexts that match the parameters specified by the contextIDType and contextIDs. The third parameter, methodName, represents the name of a callback method that is called for each data context. Inside of the callback method, all methods that operate on a script-managed data source (GetFieldValue, SetFieldValue, and SaveDataSource) will operate on the data context currently being processed. Data contexts can include multiple pieces of information such as the Transaction, User, and Lender associated with a given transaction number. The list of valid context id types will vary based on the context in which the addon is running. An example of how this method is used, as well as a list of the context types allowed can be found by referencing the Processing Data Contexts topic. The contextIDs parameter can be either a single value or a Lua table of values (ie: {15631, 19867, ...}).

  • RegisterSystemEventHandler(string eventName, string handlerName): Registers the method identified by the handlerName parameter as an event handler for the system event identified by the eventName parameter.  Registered handlers will be called each time the host application fires the handler's corresponding event.  When an event is fired, any pieces of data related to the event are treated as system managed data sources and can be modified using the same methods as other system managed data sources (GetFieldValue, SetFieldValue and SaveDataSource). For a list of events for which addons may register, see the Handling System Events topic. Only one addon with a type of system can register for a given system event. Attempting to register for an event for which another system addon is already registered will result in an error. Server addons are not subject to this limitation.

  • SaveDataSource(string dataSource): Saves a modified system managed data source.