Hi Team,
Is it possible to autofill the "Issue Type" (especially sub-task) field in JIRA using the value in "Custom Field"?
When Custom Field is set to Value1, the issue type should automatically change to Sub-Task1.
When Custom Field is set to Value2, the issue type should automatically change to Sub-Task2.
When Custom Field is set to Value3, the issue type should automatically change to Sub-Task1.
--
--
Hi @Lakshmi S
If you intend to change the issue type to Bug, Story, Task, Epic or other non-Sub-Task issue types, the answer is yes it is doable.
However, it is not doable for Sub-Task as the Sub-Task must first have an existing parent.
Below is the working sample code if you intend to change it to a non-Sub-Task issue type:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours behaviours
def sampleList = getFieldById(fieldChanged)
def sampleListValue = sampleList.value.toString()
def issueType = getFieldById(ISSUE_TYPE)
if (sampleListValue == 'Option 1') {
issueType.setFormValue('Bug')
} else if (sampleListValue == 'Option 2') {
issueType.setFormValue('Task')
} else if (sampleListValue == 'Option 3') {
issueType.setFormValue('Story')
} else if (sampleListValue == 'Option 4') {
issueType.setFormValue('Sub-task')
}
Please note the sample code above is not 100% exact to your environment. Hence, you will need to modify it accordingly.
Below is a screenshot of the Behaviour configuration:-
Below are a couple of test screenshots for your reference:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
Its not working for me. Did I miss anything ?
Sorry I forgot to inform the field Product Type is multi selection list.
Please find attached screenshots for your reference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Lakshmi S
In your case, you are testing with a Multi-Select List, not a single Select List.
But you cannot select multiple options from the List for this scenario. So it is pointless to convert the Multi-Select List value to a List as you have done, i.e.:-
...
...
@BaseScript FieldBehaviours behaviours
def ProductType = getFieldById(fieldChanged)
def ProductTypeValue = ProductType.value as List
Instead, convert the Multi-Select List value to a String, as shown below, and it will resolve your problem.
...
...
@BaseScript FieldBehaviours behaviours
def ProductType = getFieldById(fieldChanged)
def ProductTypeValue = ProductType.value as String
However, if you still need to convert the Multi-Select List value to a List to get the Behaviour to work, you will then need to change the if/else condition to:-
...
...
@BaseScript FieldBehaviours behaviours
def ProductType = getFieldById(fieldChanged)
def ProductTypeValue = ProductType.value as List
if (ProductTypeValue == ['Assortment']) {
issueType.setFormValue('Bug')
}
...
...
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.
Thank you @Ram Kumar Aravindakshan _Adaptavist_ , Its working now, I was able to change the main (parent) issue type based on field value. There is no possibility to change the sub-task. This is our main requirement "Change the sub-task(we have 4 sub-tasks) based on custom field value) ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Lakshmi S
Great to hear the solution worked. :-)
In your last comment, you asked:-
There is no possibility to change the sub-task. This is our main requirement "Change the sub-task(we have 4 sub-tasks) based on custom field value) ?
No, this is not possible. Using the Issue Picker is impossible to switch to a Sub-Task type as the Sub-task issue type is not displayed.
Please accept the answer.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.