Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Script runner - Fast-track transition based on custom field value

Greetings :

I am currently looking to achieve a situation where workflow auto transition would be done based on triggers based on custom field value. I am using Script Runner add-on which has in-built feature to do so.

I have chosen Generic Event to fire the trigger and condition as cfValues['customfield_12345'] == 'xyz'

provided target field is a free text field. However i am not able to make it working, any idea what am i missing?



1 answer

1 accepted

1 vote
Answer accepted

To be more precise, can you please explain with a complete example?

My understanding is, you need a script to push an Issue from one state to another state when the value of 'customfield_12345' is set to 'xyz'. Am I right?

Yes Mahesh, you got my requirement.

Basically, you need to fire a trigger. But, since it happens from a simple field value edit, you cannot go via a workflow post function. Please question me if this is not clear. smile

It can be solved using a Scripted field.

  • Create a scripted field 'xyz'. Add to field configuration & hide it from the screens.
  • This scripted field should take the 'customfield_12345' value and check whether it is 'xyz' or not.

IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField samp = customFieldManager.getCustomFieldObjectByName("customfield_12345_Name")

String sampVal = (String) issue.getCustomFieldValue(samp)

log.debug (" " +
CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class);
String comment = "Moving to B state since Sample value is xyz";
commentManager.create(issue, currentUser, comment, true);

  • Specify the ResolutionId and JIRA status Id in setResolutionId and setAction respectively.

Kindly let me know the results. The above code could be used as a reference. Apologies, I couldn't test and provide the exact code since I'm not in my work station. smile

Hi Mahesh, 

Thanks for your reply, unfortunately we cannot create any new custom fields since this project is already live and we could not make any such changes.

However i found one solution to do this is with Script Runner plugin's listener (Fast-track transition an issue). As of now its not working for me but i am trying it sort it out. Thanks for your help so far.

@Jamie Echlin (Adaptavist)

Hello Jamie,

Can you please help in sorting the issue with Script Runner plugin's listener (Fast-track transition an issue).


In the 'Fast-Transition an Issue', we can provide the condition and a transition Id, which moves when it is true. Please provide the below script in the condition.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueImpl
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
  boolean status = false
	IssueManager issueManager = ComponentAccessor.getIssueManager()
	CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
	CustomField myCustomField = customFieldManager.getCustomFieldObjectByName("custom_field_Name")
	String myCustomFieldVal = (String) issue.getCustomFieldValue(myCustomField)
	status = true
	return status

And then, provide your transition Id in the Action dropdown.


Like Chhaya_Gadade likes this

Great,it works.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

36 views 0 1
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