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.
How to enable
Go to Profile > Project Mapping > Rules
Press Create rule to create a new rule
Once created, press the Edit (Cog Icon) Button.
Once in the Rule configuration press the Edit button to configure a Rule.
Now Press Script Configuration
Once press you will now see the configuration for the Script Rule.
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.
Testing Script Rule
Once the Script has been added, Select a Test Case.
Press Run
Once processed there will be an output of the Results. Allowing you to review if the correct outcome has occurred. For example below.
Results Output
Within the Results output there is 3 sections. These sections are:
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.
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'));
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.
setMatch(true)
For example, the condition below will only set the rule as a match if the sender is “ryan@thepluginpeople.com”.
if (message.getHeader('from') == "ryan@thepluginpeople.com") { print("Sender is correct: " + message.getHeader('from')); setMatch(true); }
Available Script Context
API | Notes |
---|---|
| Get body content of email. Not available for pre-processing script task. |
| Gets the Subject content of email. |
| Get all headers of a message. |
| Get value of a message header Parameters
|
| Set the value of a message header Parameters
|
| Adds output that is recorded during execution and shown in the processing report. Parameters
|
| Set the processing outcome of the script Parameters
Note: |
| Field processor and Script Rule only. Map - JavaScript | MDN |
| Searches within string values for matching content.RegExp - JavaScript | MDN |
| 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