...
mapList: A list of all Result Maps that should have issue association resolved based on the Message ID.
onIssueIDField: The ID of the custom field the Message ID of the email will be stored on the issue.
Script
Code Block | ||
---|---|---|
| ||
if(jemhUtils.getCatchEmailAddress()) { // Gets the 'initial'first catchCatch emailEmail address,Address whichfor initiallythe matchedemail to create the 'original' ResultMap 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 to(based on addressee Domain Rules only) with each resultMap based on the '_jemh_recipient' key. If Nono project is found, the ProjectMapping default Project Key of the Default Project Mapping will be used // Establishes only the Project Key for the Result Map jemhMapperUtils.findProjectKeyForResultMaps(resultSetList); // Sets the customField Id used for Issue Association. // 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 whichthat 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"); } |
Example Emails
The following example emails can be used to validate issue association via Script.
...