The Preprocessor Method

You are here:


A Preprocessor is a script that pre-populates a Custom Field with dynamically generated data.

Code Examples

Code examples can be found here: Dynamically populate Custom Tool fields with PowerShell

When to Use a Preprocessor

Use a Preprocessor when you need to collect Lookup Values in a Custom Field where those values might change over time or under certain circumstances.

Examples include a list of local user accounts on a computer, a list of hotfixes installed on a computer, services, or maybe a list of current virtual machines on a host. Preprocessors allow you a great opportunity to expand System Frontier functionality

How the Preprocessor Works

A Custom Tool that needs to have a dynamically populated field will call a separate Custom Tool to get that information. Ergo, in the example below, on the Custom Tools page (Tools > All tools), you’ll see the Preprocessor tool called, Preprocessor Sample, and the parent Custom Tool called, Dynamic Field Sample.

Preprocessor tool (Preprocessor Sample) and the parent Custom Tool (Dynamic Field Sample)

If we take a look at the parent Custom Tool below, we’ll see that the Script/Executable refers to the script that needs to run the action desired.

Custom Tool showing Preprocessor usage

In the User Input Fields are two items:

  1. ServiceAction. Lookup Values of: View, Stop, and Start.
  2. ServiceListBox. No Lookup Values because this User Input Field will use a Preprocessor to fill in those values.

There is a section labeled Preprocessor. In the dropdown box, we’ll select the script that we want to run that will populate the Lookup Values for the ServiceListBox input field. The Preprocessor will run before the parent Custom Tool’s form loads, so the values will already be populated in the ServiceListBox field when it loads.

In the actual Script/Executable script, in this case DynamicFieldSample.ps1, you’ll see on line 23 below that it takes as inputs: a computer name, a service name, and a service action.

Structure of a Custom Tool that will use a Preprocessor for an input called ServiceName (which will come from a ServiceListBox selection in this case)

After a user provides the computer name and selects the action to take (stop or start the service), he still needs to select a service on which to perform the action. A list of services is generated by the Preprocessor script to populate that field and provide a selection for the user. Here’s what the Dynamic Field Sample tool looks like when it’s opened:

Example of a Preprocessor populated ServiceListBox field

A Preprocessor script will collect data that’s needed to create the ServiceListBox values and convert that data (usually stored as an array) into JSON. System Frontier converts the JSON into the Lookup Values used in the parent Custom Tool.

Be sure to read the Custom Fields article for more information. The Dynamically populate Custom Tool fields with PowerShell article will give more specifics and describe how to create the Preprocessor Custom Tool.

Was this article helpful?
Dislike 0