parse description/summary update custom field

I am new to groovy, so I need some guidance:

1.) I'm trying to write a listener that executes on ticket creation with the following variables:

def issueManager = ComponentAccessor.getIssueManager()
def currentIssue = issueManager.getIssueObject("TestProject-1")

the rest of my codes works when currentIssue is static, like above with the ticket number as the string ("TestProject-1").  How can I get the key of the issue that triggered my listener...... event.issue.getKey() and event.issue.getID() did not work.

2.) How can I extract the summary of a ticket?  I would eventually like to do some regex, searching not modifying. but I am not sure what classes I need, and methods to use, maybe currentIssue.summary()?

 

2 answers

I think you just need to do

event.issue.key

The issue navigation property is really just calling the getIssue method on the IssueEvent object. Likewise getKey on the issue object should get you the key.

Take a look at the other methods on the Issue class's JavaDoc. .getSummary() (which Groovy lets you abbreviate to just .summary) should get you the summary.

0 votes

Take a look at the example at https://scriptrunner.adaptavist.com/4.3.5/jira/listeners.html#_custom_listener_example

Try

def mIssue = ComponentAccessor.getIssueManager().getIssueObject(event.issue.getId())

def key = mIssue.key


Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,110 views 13 19
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot