Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie to script runner work flow... how do you transition based on a particular custom field. (

WGS Support
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 1, 2019

I'm new to the script runner plug in....  this is what I am trying to do:

 

We have a custom field called: discipline that is a drop down list.. where you can only select 1 option.

When the person entering the ticket selects discipline = QA for example..

I want the ticket to automatically move to the QA review que.. instead of the initial status.

Here are the 2 lines that I have attempted so far:

assert cfValues['Discipline']== ('QA')

cfValues['Discipline']== ('QA')

and then I found the custom field ID: id=12200

 

Thanks,

Rob Lazorchak

2 answers

0 votes
Kyle Moseley
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 6, 2019

I would suggest using a SR workflow fast track post-function. This post function will live on the 'Create' transition. It will automatically forward certain issues (based on your condition) to a specific status. Setup your condition similar to this:

cfValues['My Select Field'] == "Option Name"

SR Documentation here

Rob Lazorchak February 6, 2019

Thanks for the reply... This is what I have: 

 

cfValues['Discipline'] == "QA"  

Then action is To QA Review (711) 

With a comment in the additional issue actions section. 

 

TOfields.JPG

Rob Lazorchak February 6, 2019

From Post functions editor: 

Fast-track transition an issue (condition & additional actions apply)
Action: To QA Review (711) will be applied
Note that this should go after the Fire Event function.

Fast track an entered issue to QA

Then in the payload I don't see any mention of this being called: 

{
"full.module.key": "com.onresolve.jira.groovy.groovyrunnerrungroovy-function (java.lang.String)",
"canned-script": "com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.FasttrackTransition (java.lang.String)",
"class.name": "com.onresolve.jira.groovy.GroovyFunctionPlugin (java.lang.String)",
"issue": "TO-28 (com.atlassian.jira.issue.IssueImpl)",
"passesCondition": "true (java.lang.Boolean)",
"transientVars": {
"issue": "TO-28 (com.atlassian.jira.issue.IssueImpl)",
"configuration": "com.opensymphony.workflow.config.DefaultConfiguration@15773e85",
"issueProperties": "{} (com.google.common.collect.EmptyImmutableBiMap)",
"currentSteps": "[SimpleStep@27[owner=, actionId=0, status=open]] (java.util.ArrayList)",
"store": "com.opensymphony.workflow.spi.ofbiz.OfbizWorkflowStore@47fbb579",
"descriptor": "com.atlassian.jira.workflow.ImmutableWorkflowDescriptor@dcb6a0b",
"entry": "com.opensymphony.workflow.spi.SimpleWorkflowEntry@c062238",
"oldStatus": "IssueConstantImpl[[GenericEntity:Status][sequence,8][statuscategory,2][name,PM Review][iconurl,/][description,Program Manager Review. \nWhen tickets are in this status it means the Program manager is reviewing the ticket to make sure: \n1) This is a priority task that he wants to get completed. \n2) There is proper funding for the task. \n3) The task has the appropriate priority assigned to it.][id,10000]] (com.atlassian.jira.issue.status.StatusImpl)",
"context": "com.opensymphony.workflow.basic.BasicWorkflowContext@2d3ce1f6",
"createdStep": "SimpleStep@27[owner=, actionId=0, status=open] (com.opensymphony.workflow.spi.SimpleStep)",
"originalissueobject": "null (org.codehaus.groovy.runtime.NullObject)",
"actionId": "1 (java.lang.Integer)",
"pkey": "TO (java.lang.String)",
"changeItems": "[com.atlassian.jira.issue.history.ChangeItemBean@54740238[fieldType=jira,field=assignee,from=<null>,fromString=<null>,to=xxxx,toString=xxxxx,created=<null>], com.atlassian.jira.issue.history.ChangeItemBean@47cde318[fieldType=jira,field=status,from=10000,fromString=PM Review,to=10000,toString=PM Review,created=<null>]] (java.util.LinkedList)"
},
"log": "org.apache.log4j.Logger@28198289"
}

0 votes
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 4, 2019

Hello Rob,

The condition provided by in the answer below should work for you:

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

Also, since you are not an experienced with groovy scripts, would you like to try a simpler solution for your case?

I believe that Automation for JIRA (300 free executions per month) would be more intuitive to update your issue status when a custom field is edited. You would just need a rule like the one below:

Screen Shot 2019-02-04 at 13.51.22.png

Please, let me know if the information above helps you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events