...
Below is some additional information and examples about what can be achieved within the Script Field Processor.
Script Context
API | Notes |
---|---|
| Get body content of email. Not available for preprocessing 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
|
| 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. |
| 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. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map |
| Searches within string values for matching content.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp |
Setting Custom Field Values via Script
...
Here you can see that the script has found all of the headers and their values and has set this onto the Paragraph Custom Field.
...
Dynamically setting a customer request type from X-Priority mail header
We can use
Example Script
Code Block |
---|
var xprio = message.getHeader('X-Priority');
if (xprio!==null) {
print('X-Priority = '+xprio);
switch (xprio) {
case "1":
print('case 1');
resultMap.set("requesttype", "Technical support");
break;
default:
print('case default');
resultMap.set("requesttype", "Emailed request");
break;
}
} else {
print('no X-Priority found');
} |
Test Case
Code Block |
---|
MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Subject: test subject
From: andy@thepluginpeople.com
To: support@thepluginpeople.com
X-Priority: 1
Content-Type: text/plain; charset=UTF-8
CHANGE BODY!!! |
Processing Report
...