I have three fields, office, department, username, they are all hidden by default.
when I click To_do step, then display username, office, department;
and In the next_1 step, display username, office, hide department;
And in next_2, display username, department, hide office;
When done, all three fields are displayed.
How could I use Groovy to do that ,have someone give an example?
thanks.
Hi @yundong.li ,
in order to put in place that, you should setup a Behaviour provided by Script Runner.
https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html
Here a tutorial https://scriptrunner.adaptavist.com/latest/jira/tutorials/behaviours-tutorial.html
in order to show/hide a specific field you should use setHidden method based on your conditions :
def myFirstField = getFieldByName("custom_field_name");
myFirstField.setHidden(false/true);
Hope this helps,
Fabio
Thanks for your help.
Yes , I do it like this. but it cannot do what I need.
I need to get the status value of the workflow node,
and then control the display of the field according to the status value.
Do you know how to get the state value of the node ?
Sorry , I am not very good at Scriptrunner, Can you help to give an example?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @yundong.li ,
here an example that should work on your scenario :
import com.atlassian.jira.issue.Issue;
Issue issue = getUnderlyingIssue();
def field1 = getFieldByName("CUSTOM_FIELD_1_NAME_HERE");
def field2 = getFieldByName("CUSTOM_FIELD_2_NAME_HERE");
def field3 = getFieldByName("CUSTOM_FIELD_3_NAME_HERE");
field1.setHidden(true);
field2.setHidden(true);
field3.setHidden(true);
String statusName = issue.getStatusObject().getName();
if("YOUR_STATUS_NAME_HERE".equalsIgnoreCase(statusName)){
field1.setHidden(false);
}
Obviously you need to adapt this behaviour at your requirments.
Fabio
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.