Hi Team,
We have a requirement to change the custom field values in the dropdown depending on the workflow status.
For example :
Hi @Lakshmi S
Could you please clarify if you are using a Transition screen? I am asking this because if you intend to filter the List's option, this can only be done using ScriptRunner's Behaviour.
However, a transition screen will be required if you want the filtration to occur according to the transition type.
You can use the Behaviour Initialiser to trigger the filtration.
Below is a sample working code for your reference:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleList = getFieldByName('Sample List')
def options = []
if (actionName == 'In Progress') {
options = ['Option1', 'Option2']
} else if (actionName == 'Done') {
options = ['Option3', 'Option4']
}
sampleList.setFieldOptions(options)
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Behaviour configuration for your reference:-
You will need to add the Transition screens to your Workflow accordingly and ensure the list is included in it.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_. Thank you for your quick response. The script works, and the field options are displayed on a particular transition based on the filter (I added a transition screen). Still, when creating the ticket, the field does not show any value; when editing the field in that particular status, the field does not show any value. Please find the attached screenshot for your reference.
The script is :
Field on Create and edit the field to other value on particular status.
On Create, It should display all values.
On Edit, It should display the filtered values only if the ticket is in that particular status.
Is it possible. Could please suggest me?
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
I'm not sure why it's not working on your side; it's working fine on mine.
Below are a couple of test screenshots for your reference:-
1. When transitioning to the In Progress status, the options in the Sample List field are filtered to Option1 and Option2 and shown in the screenshot below:-
2. When transitioning to the Done status, the options in the Sample List field are filtered to Option3 and Option4.
Please try to disable all your third-party plugins except for ScriptRunner and try to rerun the test. I am suggesting this because, in my environment, I am only using the ScriptRunner plugin to rule out if there are any conflicts with the plugins resulting in the problem you are encountering.
I am looking forward to your feedback.
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.
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
No, This piece is perfectly working on the status transitions (I added them to the transition screen).
What I am asking is,
Field on Create and edit ,
On Create, It should display all values, but it is showing "None" (as per my screenshot above) while creating the new ticket.
On Edit, It should display the filtered values only if the ticket is in that particular status (in Progress or Done), but it is showing "None" (as per my screenshot).
I was able to display all custom field values on "Create", but when we are editing the field, its still showing "None" instead of the filter values.
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
Sorry, I misread your last comment.
So, for your case, if you want to display all the options on the Create and Edit screen and filter the options on the Transition screens, you will need to update the def options = [] declaration and include all the options in it.
Below is the updated code for your reference:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleList = getFieldByName('Sample List')
def options = ['Option1', 'Option2', 'Option3', 'Option4'] //Add all options in the List
if (actionName == 'In Progress') {
options = ['Option1', 'Option2']
} else if (actionName == 'Done') {
options = ['Option3', 'Option4']
}
sampleList.setFieldOptions(options)
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the updated Behaviour configuration:-
Once again, below are the test screenshots for your reference:-
1. If you observe the Create and Edit screens below, you will notice that all the options are available in the List.
2. Accordingly, in the In Progress transition screen, the list is filtered only to display Option1 and Option2 as shown in the screenshot below:-
3. Finally, in the Done screen, the list is filtered only to show Option3 and Option4.
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.
Its working expected. Thank you Ram! @Ram Kumar Aravindakshan _Adaptavist_ , You are the best!
Is it possible ?
Will the shortened list show up in the edit also when in that particular status instead of all values?
For example : We are in the "In Progress" status, user wants to edit that field values in that "In Progress" status, it should display those filtered values only instead all custom field values.
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 ,
Thanks for posting your question here!
It's easy, just try out Jira Automation for this or you can even use Post function in Jira.
Simply add a rule like this :
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, Good day. Jira don't have this option builtin. You can explore addons like script runner. https://community.atlassian.com/t5/Jira-Software-questions/How-to-show-custom-field-in-specific-statuses-only-hide-the-rest/qaq-p/1816591
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Mohanraj Thangamuthu ,
That's not my requirement. I want to update custom field values based on status.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can explore the automation rule to change the field value based on issue status.
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.