Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add Hyperlink to the email send out by Script Listener Edited

Hi everyone,

I have created script listener with ScriptRunner that iterates through all subtasks and their linked issues, and then the email is send out with the results.

Everything works great but I would like to know how to create a hyperlink in email body, since 

sendEmail("", "Testing", emailBody)

is giving only string back. The reason I want to do this is that the link is really long, and it doesn't look nice. So is there a way to enter HTML tag to the email body? or any other way to insert hyperlink.

Here is the code I'm using:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.fields.CustomField;
import java.text.SimpleDateFormat;
import com.atlassian.jira.mail.Email
import com.atlassian.mail.server.SMTPMailServer

IssueManager issueManager = ComponentAccessor.getIssueManager();
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issue = event.getIssue()
String emailBody
def activityField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_13001");
def findingsLinkField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_18601");

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

// Gets all subtasks of the projects.
final Collection < Issue > subTaskObjects = issue.getSubTaskObjects();
if(subTaskObjects != null && subTaskObjects.size() != 0)
for (Issue subTaskObject : subTaskObjects)
if( == "Test Review")
if(subTaskObject != null)
// Gets all linked issues of the subtasks
final List <IssueLink> issuelinks = issueLinkManager.getInwardLinks(subTaskObject.getId());
if(issuelinks != null && issuelinks.size() != 0)
for (IssueLink issueLink : issuelinks)
def mutablelink = issueManager.getIssueObject(issueLink.getSourceId())
if (issueLink.getIssueLinkType().name == "Test finding" && issueLink != null && == "open")
def activity = mutablelink.getCustomFieldValue(activityField);
def findingsLink = mutablelink.getCustomFieldValue(findingsLinkField);

// I would like to add this link to hyper link
def url = ""+ mutablelink.key +")&body=Please%20send%20a%20short%20status%20update%20for%20this%20Test%20Review%20Finding%20to%20the%20already%20entered%20recipient.%20A%20comment%20to%20the%20Finding%20will%20be%20added%20automatically%20in%20Q-Tool%20where%20the%20responsible%20QE-CS%20will%20react%20accordingly.%0D%0A"
URL obj = new URL(url)

emailBody = emailBody + "Finding: ${mutablelink.key}<br> activityField: ${activity} \n " + "Url: ${obj} "



def sendEmail(String emailAddr, String subject, String body) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if (mailServer)
Email email = new Email(emailAddr)
log.debug("Mail sent")
} else {
log.warn("Please make sure that a valid mailServer is configured")
sendEmail("", "Testing", emailBody)


1 answer

1 accepted

0 votes
Answer accepted
Danyal Iqbal Community Leader Feb 17, 2021



and then add the html hyperlink in the body.

worked like a charm :) thanks 

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you