Creating a Script

Quick Fields contains a powerful Script Editor that enables you to write VB.NET and C# scripts. Follow the steps below to create a new script.

Tip: It is important to consider the impact a script could have on the performance of your session. For events associated with documents, the script will run once for each document. For events associated with pages, the script will run once for each page. For example, if you called the e.API.ShowMessageBox method inside the OnPageCreated method, and then scanned a 200 page document, the message box would appear 200 times.

Note: For the most part, Quick Fields does not interact with a Laserfiche repository until documents are stored. As a result, if your script needs to connect to your Laserfiche repository, you must provide the connection yourself using standard Laserfiche Toolkit code. For more information on Laserfiche Server Objects, see the Laserfiche Toolkit documentation.

To create a script

  1. Within an open Quick Fields session, select Script Editor under Tools in the menu bar.
  2. You may be prompted to choose a programming language: Visual Basic (VB.NET) or C#. Choose one.

    Tip: You can also control this setting by selecting Tools, Options, Current Session, General and configuring Scripting Options. The language setting is tied to the session that is currently open, not to Quick Fields in general.

  3. Right-click one of the event folders in the Project Explorer pane, point to Add, and select Quick Fields Script.
  4. In the Select a Scripting Event dialog box, select the appropriate event for your script. In most cases, the name of the event you select will match the name of folder you right-clicked in the previous step. Select OK.

    Note: When you create a script, it is assigned to, and only available within, the active session. For example, the scripts you create in Session 1 will not available to Session 2.

  5. A new tab will appear in the Script pane, inside of which will be some code that will include:

    • Import/Using statements: A series of imports that are required to run your script.

      Tip: If your script requires additional imports, you can include them here. You must also add a reference to any namespaces that are not in your References folder. To do so, right click on the References folder in the Project Explorer pane and select Add Reference. In the Add References dialog box, choose a reference from the list or click the Browse button to locate a file.

    • Namespace: The QuickFields.Scripting namespace.
    • Class: A class named ScriptX, where X will be a different integer depending on the number of scripts associated with the session.
    • Method: The name of the method depends on the event you selected. Place your script inside of this method.
    • XML Comments: Used to explain the default blocks of code.