Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi
I want to send an email using Scriptrunner Email Post Function. The email needs to contain the URL of the issue.
Is there a built in method to do this?
or do I have to form the link manually with Base URL / project code etc.
https://blah.com/browse/CSD-14300
Hi @Tom Lister
Issues don't have an "url" attribute. If you think about it, it would not be a good idea to store that in the db because the baseUrl and the application context could change.
So yeah, making a URL out of the baseURL and issue key is the only way to go as far as I know.
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def link = """<a href=\"${baseUrl}/browse/${issue.key}\">${issue.key}</a>"""
Hi @PD Sheehan
There are some built in methods for email template e.g. this provides a list of workflow actions in the email.
${getWorkflowButtons.call()}
I was hoping for something similar for other utility functions. Is there a list of available functions.? No sign in the ScriptRunner documentation.
My next issue is how to stop the code snippet showing up in the email from the template as raw text.
And finding the right syntax for displaying the variable value.
I think I can try putting the code into the condition section.
Tom
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
PS
this embedded syntax works for me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably a matter of preference, but I like to keep the template simple and put the more complex stuff in the condition where you get better syntax checking.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@PD Sheehan
Thank you a lot, this works perfectly.
pasting the code for others (to not manually type from screen):
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.component.ComponentAccessor
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def link = """<a href=\"${baseUrl}/browse/${issue.key}\">${issue.key}</a>"""
config.ticketLink = link
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is now a simpler way to get the baseUrl.
Rather than fetching the jira application property by key (which requires an extra import), you can get it directly using a designated method:
def baseUrl = ComponentAccessor.applicationProperties.jiraBaseUrl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.