How to Use Custom Logic (Script)

Use this feature (component) to perform any type of processing that is specified by a script.

  • You can write your script, to perform any document content and metadata operations, using C# or VB.NET.

  • This feature stores information, extracts additional metadata, uses external data sources like databases, and so on.

Both the input and output properties depend on the script.

  1. Make sure that you have specified the URL.
  2. Add the component.
  3. Existing Components: Click the named link for this component to see the Configuration section:
  4. To use the scripting pane, click the See the gear icon. icon to open the script settings window.

  5. Compile: Click Compile to compile your script.
  6. To configure:

    1. C#/VB: Use the default C# or select VB scripting.

    2. Change default script to generate a relative path and file name. Optional.

      1. Input Properties: Based on configuration.

      2. Output Properties: Based on configuration.
        You can write scripts for features and in multiple places for AutoClassifier. However, the script editor usage is the same for each location.

        Note: For this reason, although the scripting UI is different for features, the code examples are the same examples that are used in the Configure triggers using scripts section above.
  7. Add the component using the Add Components as Pipelines topic.

  8. To reset the partition size, go to Configuration > Profiling > Binary Data Extraction. Optional.
  9. Existing Components: Click the named link for this component to see the Configuration section:
  10. Type in the script.
  11. Compile: Click to verify the validity of the script.
  • See the following scripting examples:

Scripting Examples

Item Property: GET

To get an item property, use the generic GET method on item object:

C#
string propertyValue = item.Get<string>("propertyName");
VB
Dim propertyValue As String = item.[Get](Of String)("propertyName")

Property Values: SET

Property values can be changed in a similar way by the generic SET method:

C#
item.Set<string>("propertyName", "propertyValue");
VB
item.[Set](Of String)("propertyName", "propertyValue")

Note: If you want to generate / handle multi-valued metadata via scripting, it is recommended to use List in favor of Array.

List<T> should be the type used for multi-valued metadata.

Item Raw Data

Item raw data: Raw data can be retrieved as a byte buffer using the RawData property.

C#
byte[] content = item.RawData;
VB
Dim content As Byte() = item.RawData

Log Entries

  • Logging: Use static methods to write entries into the log at different levels:

C#
Copy
Log.Debug("Debug message");
Log.Info("Info message");
Log.Warning("Warning message");
Log.Error("Error message");
VB
Copy
Log.Debug("Debug message");
Log.Info("Info message");
Log.Warning("Warning message");
Log.[Error]("Error message");

How to Define Assemblies and Namespaces to Import

  1. Click the See the gear icon. icon to define the namespaces to use.

  2. If you implement extra code in your script that calls third-party APIs, you will need to add the namespaces for the necessary libraries in the Namespaces textbox.

  3. Add all the Assemblies (DLL files) you wish to use in your scripts to the Admin Site\Config\ScriptingAssemblies folder from your AutoClassifier Engine install folder.

  4. If you upgrade from a version earlier than 6.1.0.0 - 18995 you must copy to \Config\ScriptingAssemblies all the previously referenced assemblies in your scripts and triggers. 
  5. For all the namespaces you want to use, add them in the pop-up text box and separate each namespaces with a new line. 

For example:

Copy
System.Text.RegularExpressions
System.Text
System.Linq
System.Collections.Generic
Newtonsoft.Json