Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You may want to create multiple issues from a single email based on the email recipients. For example, a customer might CC another email address within your organisation specific to a different Jira Project. In this case, one email should create two issues, one for each recipient.

Implementation

...

Status
colourGreen
titleSince 3.4.11

The jemhUtils class can be used to create a list of Result Maps for each Catch Email address match in the email. This is specific to the Profile the script is used in. Please see the following example:

...

Code Block
breakoutModefull-width
if(jemhUtils.getCatchEmailAddress())
{
    // Gets the first Catch Email Address for the email
    var caughtRecipient = jemhUtils.getCatchEmailAddress().// For a more detailed description of this method and its implementation please see the following Documentation Page: https://thepluginpeople.atlassian.net/l/cp/w09QeNY4
if(jemhUtils.getCatchEmailAddress())
{
    // Gets the first Catch Email Address for the email
    var caughtRecipient = jemhUtils.getCatchEmailAddress().getAddress();
    
    // Sets the Result Map's '_jemh_recipient' to the actual caught Email address
    resultMap.put("_jemh_recipient", caughtRecipient);
    
    // Creates a list of Result maps from the email addressees that are Catch Email Address matches with the '_jemh_recipient' key containing the Catch Email Address.
    var resultSetList = jemhUtils.createResultSetForAdditionalMailboxAddresses();
    
    // Adds the resultMap to the List of additional resultMaps. This is done to make iterating through each resultMap for issue association easier
    resultSetList.add(resultMap);
    
    // Finds the Project key associated (based on addressee Domain Rules only) with each resultMap based on the  '_jemh_recipient' key. If no project is found, the Project Key of the Default Project Mapping will be used
    // Establishes only the Project Key for the Result Map
    jemhMapperUtils.findProjectKeyForResultMaps(resultSetList);
    
    
    // The Issue keys for each resultMap are resolved based on the Message ID. To summarize the method, a hash of the Message ID (we have to hash to ensure the value can be queried with JQL) of the email is used to establish if any other issues
    // in the project have the same hash in the custom field specified by the the 'externalIdField'. Any Issues found via a bounded JQL query (max 10) are sorted by creation date (Ascending). As this is a 'Filtered' method variant, any 
    // thread match conditions defined in the profile are run against the viable issues. removing any issues that do not meet this criteria. Finally a single (created first and valid) issue is selected, and the issueKey is added to
    // the Result Map. If no match is found, the hashed Message ID is added to the specified Custom field (e.g. "customfield_10122") for future association
    
    // TLDR: Issues are resolved for each of the provided Result Maps based on a hashed Message ID stored on the Custom field e.g. "customfield_10122"
    // Adds pre-existing Issue Keys for previously established Projects in the Result Map
    jemhThreadUtils.resolveFilteredIssueAssociationByMessageIdForAdditionalResultMaps(resultSetList, "customfield_10122");
    
    // Based on the defined project in the result map, and the '_jemh_recipient', any valid Domain Rule configurations and project mapping values are applied to the result set, as if the email had been mapped to a specific project.
    // Add in all appropriate Field values from the Domain Rule and its parent Project Mapping i.e. Issue Type Priority, etc.
    jemhMapperUtils.applyProjectMappingDomainRulesToResultMaps(resultSetList);
}
else
{
    print("No Catch Email Address found between Email Recipients and Profile > Email > Catch Email Address");
}

...

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
Message-ID: <ISSUE-COMMENT-TESTCASE-TEST@mail.gmail.com>
In-Reply-To: <ISSUE-CREATION-TESTCASE-TEST@mail.gmail.com>
Subject: This is a starting email template, update as required
From: "Andy Brook" <user1@test.com>
To: test@test.com, blue@test.com
Cc: green@test.com
Content-Type: text/plain; charset=UTF-8

some text

Outcome

...

Associate with External ID via Script

The jemhThreadUtils class also allows for issues to be associated via an external ID. This allows values other than the Message ID to be used. As an example, a value from the Subject. Typically this requires some additional configuration as the external ID must be identified in the email manually. For example in the Subject of the email, or via regexp.