Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

is it possible to have a listener define a projectKey from whatever project a event is triggered by?

is it possible to have a listener define a projectKey from whatever project a event is triggered by?


Below is a script i put together for auto distance calculations that i need to deploy to all of my projects. As of now i am constrained by the projectKey = 'XCAT' 

Is there any way to define the projectKey based on whatever project the issue that triggers this event belongs to. in this case any time a issue is created or a issue is updated i want this to fire across all projects.


// get custom fields
def customFields = get("/rest/api/2/field")
.findAll { (it as Map).custom } as List<Map>

def input1CfId = customFields.find { == 'Footage' }?.id
def outputCfId = customFields.find { == 'Mileage' }?.id
def projectKey = 'XCAT'

if (issue == null || ((Map)issue.fields.project).key != projectKey) {"Wrong Project ${issue.fields.project.key}")

def input1 = issue.fields[input1CfId] as Integer
def output = 0
if (input1 != null) {
output = input1 /5280

if(input1 == null){
output = null

.header("Content-Type", "application/json")
(outputCfId): output

1 answer

1 accepted

1 vote
Answer accepted

Hi @Alex Sprague what event is used to trigger the listener? Is it issue updated? If so, you could use:

def projectKey = issue.fields.project.key

You can find some examples here: 

@Martin Bayer _MoroSystems_ s_r_o__ The event triggers are issue updated and issue created. Thank you for your quick reply! 

Hi @Alex Sprague you are welcome, but did my information help or you need more information? :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

184 views 1 6
Read article

Atlassian Community Events