Script Field Processor

Summary

When JEMHC Processes messages, the content (subject/body) can be subjected to Field Processors, which are specialised parsers. The script field processor allows you to use this information to create custom JavaScript conditions within JEMHC.

How to enable

  1. Go to Profile > Project Mapping > Field Processors

  2. Press edit Edit in the top right corner.

  3. Then select Yes on the Script Field Processor.

  4. You will now see that a section is shown allowing you to configure the Script Field Processor.

Testing the Script

  1. Select a Test Case

  2. Press Run.

  3. 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:

  1. Directive Values - This is a list of Custom Field values that have been set by the Script. e.g. using resultMap.set('labels', "label1,label2,label3,label4");

  2. Script Output - This is where the Print values are output, allowing for additional information to be displayed. e.g. using print(`Body: \n${message.getBody()}`);

  3. Script Evaluation Time Metrics - This is used to identify how long it took to evaluate the script against the selected Test Case.

Available Script Context

The another ticket with different subject “ATH201125 –405034 – Visit Early Termination (A)”. It is showing in the auditing page but the subject was never processed & new created was not created , that is what I mentioned instead of creating new ticket , the existing ticket TDAS-55011 was commented. API

Notes

The another ticket with different subject “ATH201125 –405034 – Visit Early Termination (A)”. It is showing in the auditing page but the subject was never processed & new created was not created , that is what I mentioned instead of creating new ticket , the existing ticket TDAS-55011 was commented. API

Notes

message.getBody()

Get body content of email. Not available for preprocessing 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

issue

If the email being processed is commenting on an existing issue, then this context will contain the field values for the related issue. Allowing for this data to be used within the Script. Format used is as per the Get Issue response from the Jira REST API.

Note: This is only available within the Script Custom Field default and the Script Field Processor.

For more info about using Issue Data see: https://thepluginpeople.atlassian.net/wiki/spaces/JEMHC/pages/3861676043/Manipulate+Issue+data+in+Scripting+features#Showing-the-JSON-object-Values-and-structure

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

Used to set issue field values. See Map - JavaScript | MDN for usage.

RegExp

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

Script Examples

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

Script Exceptions

TimedOut exception

When you see the following exception it means that the Script took too long to complete and as a result JEMHC stops the Script from running resulting in the following exception.

LambdaException

This exception occurs when the script is too large. Scripts must be less than 6291456 bytes (6.29MB) in order to run.

SyntaxError

This error means that there is something wrong with the script which is stopping it from running. Typically a character is missing which makes the script invalid. e.g. Missing a “)”.

ReferenceError

This error is used when you try an use a script Context that does not exist. e.g. when using “prin” instead of ”print”.

TypeError

This error occurs when you try and use a Function that does not exist within that Script Context and as a result cannot be used.