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

In script runner is there a way to run the script post-commit on an issue create?

Deciderio Bisco Dec 11, 2013

In script runner I created a custom listener. When running on issue create, no field values are returned(as if no field values are created in the database).

This only works when we edit the issue.

My guess is the script is running before the issue is commited.

Is there a way to run the script post-commit on an issue create?

4 answers

0 votes
Henning Tietgens Dec 11, 2013

How do you read the field values in the listener? Do you use the issue from the event?

Deciderio Bisco Dec 11, 2013
IssueManager issueManager = ComponentManager.getInstance().getIssueManager()

CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager()

ComponentManager mycomponentManager = ComponentManager.getInstance()

UserUtil userUtil = mycomponentManager.getUserUtil()

def watcherManager = ComponentAccessor.getWatcherManager()

Issue issue = event.getIssue()

//Issue issue = issueManager.getIssueObject("XXX-64" )

User currentUser = event.getUser()

System.out.println ("CurrentUser is " + currentUser.getDisplayName())

System.out.println ("CurrentUser Email is " + currentUser.getEmailAddress())

CustomField customField = customFieldManager.getCustomFieldObjectByName( "Corp ID" )

// retrieves the custom field value object from the issue

Object customFieldValue = issue.getCustomFieldValue( customField )

System.out.println("Corp ID is " + issue.getCustomFieldValue( customField ).name)

User user = userUtil.getUser(issue.getCustomFieldValue( customField ).name);

// prints value to console

System.out.println ("Corp ID Full User Name is " + user.getDisplayName())

System.out.println ("Corp ID Email Address is " + user.getEmailAddress())

System.out.println( customFieldValue )

def p4Project = customFieldManager.getCustomFieldObjectByName( "P4 Project" )

0 votes
Deciderio Bisco Dec 11, 2013

We are having a problem trying to get a script to run post creation. It only seems to work on edit, does not work on creation.

On edit, the script (ExampleListener) is run from here:

But on create, it is not run, even though we set it as a post function.

0 votes
Deciderio Bisco Dec 11, 2013

Can we use the functions issueManager, CustomFieldManager etc in a post function or do we have to use different functions and classes such as AbstractJiraFunctionProvider?

0 votes
Henning Tietgens Dec 15, 2013

A listener must not be triggered in a post function. A listener listens on the events you define while you configure the listener. You should choose the "Issue Created" (instead of "Issue Updated") event to get the listener triggered after an issue was created. Remove the post function in the workflow, you can't call listeners from there.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

2,448 views 6 15
Read article

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