Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
Note

In Closed Beta - not yet publicly available

Summary

Script rules allow you to create a Custom JavaScript condition that needs to be met for this rule to be matched.

...

  1. Go to Profile > Project Mapping > Rules

  2. Press Create rule to create a new rule

    Image RemovedImage Added
  3. Once created, press the Edit (Cog Icon) Button.

    Image RemovedImage Added
  4. Once in the Rule configuration press the Edit button to configure a Rule.

    Image RemovedImage Added
  5. Now Press Script Configuration

    Image RemovedImage Added
  6. Once press you will now see the configuration for the Script Rule.

    Image RemovedImage Added
  7. Once the Script has been configured, you will then need to go to Rule Configuration and press Active as this will result in the Rule being enabled.

    Image RemovedImage Added

Testing Script Rule

...

  1. Success or Error - This is used to define if the Script was able to be processed correctly or if there was an error with the script. This section also defines if the Test Case was a match or not.

  2. Script Output - This is where the Print values are output, allowing for additional information to be displayed. e.g. using print("Sender is correct: " + message.getHeader('from'));

    Image RemovedImage Added
  3. Script Evaluation Time Metrics - Used to identify how long it took to evaluate the script against the selected Test Case.

How to set Rule as a Match

In order for the Rule to be seen as a match you will need to ensure that the Script defines that there was a match. This is done by using the following line within the Script.

...

Code Block
if (message.getHeader('from') == "ryan@thepluginpeople.com")
{
    print("Sender is correct: " + message.getHeader('from'));
    setMatch(true);
}

Available Script Context

API

Notes

message.getBody()

Get body content of email. Not available for pre-processing script task.

message.getSubject()

Gets the Subject content of email.

message.getAllHeaders()

Get all headers of a message.

message.getHeader(name)

Get value of a message header

Parameters

  • name the name of the header to get

message.setHeader(key, value)

Set the value of a message header

Parameters

  • key (String) the name of the header to set

  • value (String) the value of the header to set

print(str)

Adds output that is recorded during execution and shown in the processing report.

Parameters

  • str (String) the string to be recorded

setOutcome(outcome, reason)

Set the processing outcome of the script

Parameters

  • outcome (String) the outcome type

  • reason (String) the reason for the outcome

Note: outcome must be written in all capitals. Valid outcomes are (IGNORE, FORWARD, DROP)

resultMap

Field processor and Script Rule only. Map - JavaScript | MDN

RegExp

Searches within string values for matching content.RegExp - JavaScript | MDN

setMatch(true)

This is used to define that the script rule is a match. This will result in that Rule and Project being used to process the email

Script Examples

See the following page for some example use cases: Use Script Rule