Context: I’m setting up an automation rule in Jira Service Management (JSM) to handle incoming emails. The objective is to check if the email body contains a specific issue key (formatted as JSM Number: VPLSRV-xxxxx). If the issue key is found, I want to add the work notes from the email as a comment on the existing issue. If no issue key is found, a new issue should be created.
Specific Requirements:
Email Format Example:
Number: ABC123
JSM Number: ABCD-149
Work_notes: More info added

Objective:
- If the email contains an issue key:
- I want to check if an issue with that key already exists in JSM.
- If the issue exists, I want to add the content under
Work_notes: as a comment on the issue. - If the issue doesn’t exist, I want to create a new issue.
- If no issue key is found in the email:
- I need to create a new issue in JSM using the email details.
Steps I’ve Taken So Far:
- Triggered the Rule when an incoming email is received.
- I use a custom automation rule to extract the issue key (formatted as
ABCD-xxxxx) from the email body. - I use this issue key to search for an existing issue in JSM.
- If an issue is found, I add the content of
Work_notes from the email as a comment on the existing issue. - If no issue is found, I create a new issue with the details from the email.
Challenges:
- Issue with Searching for Existing Issue by Key: When I try to use the extracted issue key to search for the issue in JSM, I’m getting errors related to the search query being incomplete or invalid.
- Handling of Empty Issue Key: I want to make sure that if no issue key is found in the email, the rule falls back to creating a new issue rather than failing.
Questions for the Community:
- What is the best way to extract the issue key from the email body and use it in automation to check for an existing issue?
- How can I ensure that the search for an issue by the extracted issue key works reliably?
- Are there any best practices for handling cases where the issue key is missing from the email body?
- What would be the best approach to add the work notes as a comment on the existing issue, once it is found?