/
Replicate the native Jira email handler

Replicate the native Jira email handler

This script is run by the SIL email handler to process an incoming email in the same manner as JIRA's default Create issue or add comment email handling option.

To use this script, you will have to modify the destination projectKey and issueType for your purposes.

IncomingEmail mail = getIncomingEmail(); string issueKey = matchText(mail.subject, "[A-Z][A-Z]+-[0-9]+"); // find an issue key in the subject if(isNull(issueKey)) { // if no issue key found, create a new issue string [] fields = {}; fields += {"reporter", getUserByEmail(mail.from[0]).key}; fields += {"assignee", getUserByEmail(mail.to[0]).key}; string newIssue = createIssue( "PROJ", //projectKey "", //parentIssueKey "Task", //issueType mail.subject, //summary "Medium", //priority mail.body, //description {}, //components "", //dueDate "", //estimate "", //security_level fields //custom_fields_mappings ); attachAllFilesFromEmail(newIssue); %newIssue%.watchers = getUserKeysFromEmails(mail.cc); } else { // if issue key found in subject, add a comment addComment(issueKey, currentUserKey(), mail.body); }

 

Related content

Mail Handler
More like this
Copy a custom field value to another field when changed
Copy a custom field value to another field when changed
Read with this
How to receive email notification with issue details upon successful creation of issue
How to receive email notification with issue details upon successful creation of issue
More like this
Assign issues automatically based on workload
Assign issues automatically based on workload
Read with this
attachAllFilesFromEmail
attachAllFilesFromEmail
More like this
Create custom JQL functions for nested issue reporting
Create custom JQL functions for nested issue reporting
Read with this