Hi Team,
Could you please let me know below if it's possible in Jira.
We have two custom fields
1. Intake Type (select list)
2. Impact Location (checkboxes).
When a user select option from select list ( ex: network), and if one option is selected on checkbox (ex: US) a issue related should be created in another project (name : Infra project). If the user select two options two issues should be created, if three options selected three issues should be created and if the user select (ex: Global option) a total of 5 tickets should be created in Infra project.
Note: The tickets in other project should be created during a workflow transition in first Project.
Thanks
Hi @niranjan
From your requirement, it seems more related to a ScriptRunner Behaviour.
Since you require the Issue to be created based on the options selected on two fields, you will need to create two separate Server-Side Behaviour configurations.
And from the Server-Side Behaviour configuration, you will need to trigger the issue creation. This can be done using ScriptRunner's HAPI.
Please confirm if this meets your requirement and I will provide an example script.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ Please provide me the script which will resolve this issue.
Note: The tickets in other project should be created during a workflow transition in first Project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @niranjan
As mentioned in my previous comment:-
Since you require the Issue to be created based on the options selected on two fields, you will need to create two separate Server-Side Behaviour configurations.
And from the Server-Side Behaviour configuration, you will need to trigger the issue creation. This can be done using ScriptRunner's HAPI.
You will need to create 2 Server-Side Behaviour configurations. The first is for the List, and the second is for the Checkbox.
Below are the example working Server-Side Behaviour code along with screenshots of the configuration for your reference:-
1. Server-Side behaviour code for the List:-
import com.adaptavist.hapi.jira.issues.Issues
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def list = getFieldById(fieldChanged)
def listValue = list.value
def checkbox = getFieldByName('Checkbox')
def checkboxValue = checkbox.value.toString()
if (listValue == 'Option 1' && checkboxValue == 'Global') {
Issues.create('EX', 'Story') {
setSummary('Triggered via Behaviour')
setDescription('This is an example')
}
}
Below is a screenshot of the Server-Side Behaviour configuration for the List:-
2. Server-Side Behaviour code for the Checkbox:-
import com.adaptavist.hapi.jira.issues.Issues
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def checkbox = getFieldById(fieldChanged)
def checkboxValue = checkbox.value.toString()
def list = getFieldByName('List')
def listValue = list.value
if (listValue == 'Option 1' && checkboxValue == 'Global') {
Issues.create('EX', 'Story') {
setSummary('Triggered via Behaviour')
setDescription('This is an example')
}
}
Below is a screenshot of the Server-Side Behaviour configuration for the Checkbox:-
Please note that the sample working codes above are not 100% exact to your environment. Hence, you will need to make the required modifications.
If you observe the codes provided for the List's Server-Side Behaviour code, the List is initialised as:-
def list = getFieldById(fieldChanged)
Similarly, for the Checkbox's Server-Side Behaviour code, the Checkbox is initialised as:-
def checkbox = getFieldById(fieldChanged)
This is required to identify which field makes the change.
Also, this Behaviour configuration is only mapped to the Mock project. Hence, when the Behaviour is triggered from the Mock project, a new issue is created in the Example project.
In addition to that, in both the Behaviour codes, to create the new Issue in the Example project, I am using ScriptRunner's HAPI feature to simplify the process, i.e.:-
Issues.create('EX', 'Story') {
setSummary('Triggered via Behaviour')
setDescription('This is an example')
}
I am also including a couple of test screenshots for your reference:-
1. When the is started, both the Mock and Example projects are empty without any issues, as shown in the screenshots below:-
2. Next, I am going to try and trigger the Behaviour on the Create screen of the Mock project as shown in the screenshot below:-
4. When Option 1 is selected from the List and the Global option is selected from the Checkbox, as expect,ted a new issue is created in the Example project as shown in the screenshot below:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You definitely can create ticket(s) from a ScriptRunner Post-Function:
And it definitely can be conditional on Custom Field values. An elaborate example is here:
In that example @Ashraful Hasan [Adaptavist] is using a Custom Listener, although I _think_ it could be done as a Post-Function?
But I'm definitely not a ScriptRunner expert, so maybe it has to be done as a Listener. Maybe some experts could weigh in?
(Since you're on Data Center, I would consider/recommend that you do this Automation for Jira, which can easily be triggered by an Issue Creation.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.