Hello Everyone,
I wanted to know, how we can hide field from transition screen and from specific workflow using script runner.
Thanks and Regards,
Jyoti
Hi, @Jyoti Kumari
1. Go to ScriptRunner -> Behavior
2. Add new Behavior
3. Add mapping (for what project and issuetype it must work)
4. Select required workflow
5. Select field, you want to hide
6. Turn trigger Shown to Hidden
7. Add condition, when it must happen. For this - press Add condition, then select Workflow action, and select required transition
Thanks for this example, but I want to hide this custom field from the transition screen for closed workflow state from some projects and want to unhide it from specific project, which is using same transition screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, @Jyoti Kumari
If it's for different workflows, I'm affraid it can't be made in one behaviour. You'll have to make 2+ behaviours.
If some projects share one workflow, you can make one behaviour for them, and configure correct mapping, select there required projects.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Jyoti Kumari
Can you provide more information about the problem you are trying to solve by hiding the field? Why can you not simply remove the field from the Transition screen and from the Issue screens?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need one custom field to be added automatically on closed workflow state ,as it is mandatory for single project.This field is not require in any other projects transition screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I recommend that you create a separate transition screen and workflow for that one project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great idea. And I think, it can be combined with Conditions, which transition to show.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Evgeniy and Trudy Claspill,
We are avoiding to create multiple workflows and transition screen, bcoz these can be applied for multiple projects, if handled through script runner.Is it possible to hide specific fields on specific transition screen, if screen matched.
Best Regards,
Jyoti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To answer your question, this is very much doable via ScriptRunner's Behaviour.
However, you will need to create one custom screen. This custom screen can be reused for any of your transitions.
Below is a screenshot of the sample screen that I have created.
1. Create a new screen. I have added a new screen called MOCK: Sample in the screenshot below.
2. I have added 3 custom fields to this screen, i.e. Sample Checkbox, Sample Cascade and Sample List.
Once the field has been created, associate it with whichever transition you want to use it in. For this example, I have associated this screen with two transitions, the In Progress transition and the QA transition, as shown in the screenshots below:-
1. For the In Progress transition:-
2. For the QA transition:-
Next, you will need to create a Behaviour Initialiser. Below is the sample working code that I have tested with:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleCascade = getFieldByName('Sample Cascade')
def sampleList = getFieldByName('Sample List')
sampleCascade.hidden = false
sampleList.hidden = false
if (actionName == 'In Progress') {
sampleList.hidden = true
sampleCascade.hidden = true
}
Please note that the sample working code above is not 100% exact to your environment. Hence you will need to make the required modifications.
As shown in the sample code above, you must use the actionName variable to identify which transition screen(s) you want the Behaviour to take effect.
In the sample code above, when the transition screen is used for only the In Progress transition, the Sample Casde and Sample List fields will be hidden. These fields will be visible in all other transitions.
Below is a screenshot of the Behaviour configuration:-
Below are a couple of test screenshots for your reference:-
1. I am going to transition the screen to In Progress.
2. As expected, the Behaviour has taken effect and hidden the Sample List and Sample Cascade fields. Only the Sample Checkbox field is visible, as shown in the screenshot below:-
3. Next, I will transition the issue to the QA status.
4. As expected, all the fields, i.e. Sample Checkbox, Sample Cascade and Sample List, are visible in the transition screen as shown in the screenshot below:-
The same rule applies if you intend to use this for Multiple Workflows. You can reuse that one custom screen created, associate it with the transitions you want o use and add the correct actionName to filter it.
You must also ensure the projects you are using are associated with your Behaviour.
In the updated sample code below, I have added the list of work with 2 different workflows, i.e. for two different projects.
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleCascade = getFieldByName('Sample Cascade')
def sampleList = getFieldByName('Sample List')
sampleCascade.hidden = false
sampleList.hidden = false
log.warn "======>>> ${actionName}"
if (actionName == 'In Progress') {
sampleList.hidden = true
sampleCascade.hidden = true
} else if (actionName == 'Back to open') {
sampleCascade.hidden = true
}
The first actionName is for the MOCK project in the example above, and the 'Back to Open' is for the Service Test project, i.e. a Service Desk project.
Below is the Behaviour configuration now with two projects associated with it:-
Below is a screenshot of the Service Test project's workflow:-
Below are a couple of test screenshots when testing with the Service Test project.
1. Transitoin the issue from Pending to Back to open
2. As expected, the transition screen appears, and the Sample Cascade list is hidden per the updated Behaviour code.
An additional note, in the updated sample code, I've also included a log parameter. This is to identify the actionName that is used in the transition.
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.
Hello Ram Kumar Aravindakshan,
Thank you so much for such detailed explanation, but my concern is how we can restrict this behaviour for specific transition screen, for ex- 'Mock' transition screen, which is mentioned in your example, as 'In-progress' Workflow state might available in multiple screen, so the above behaviour might work for create and edit screen also, if same field exist there.Can you give example, how we can apply this behaviour on Mock Transition screen.
Thanks and Regards,
Jyoti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your last comment, you mentioned:-
Thank you so much for such detailed explanation, but my concern is how we can restrict this behaviour for specific transition screen, for ex- 'Mock' transition screen, which is mentioned in your example, as 'In-progress' Workflow state might available in multiple screen,
Firstly, you cannot add more than one screen to a transition. Each transition is only able to add one screen. You have to be clear about this.
The example I provided is using the Mock Transition screen on Multiple Transitions.
The transition screen's name will change dynamically depending on your transition.
For example, if I add the Mock Transition screen to the In Progress transition, the actionName will change to In Progress. If it is added to the Done transition, the actionName will change to Done and so on.
Hence, you must set the condition according to the actionName, as I have shown in my previous comment.
In regards to additional filtration, for example, if you want the In Progress transition for a particular project, the if condition can be modified to something like:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleCascade = getFieldByName('Sample Cascade')
def sampleList = getFieldByName('Sample List')
sampleCascade.hidden = false
sampleList.hidden = false
def project = issueContext.projectObject
log.warn "======>>> ${actionName}"
if (project.key == 'MOCK') {
if (actionName == 'In Progress') {
sampleList.hidden = true
sampleCascade.hidden = true
} else if (actionName == 'Back to open') {
sampleCascade.hidden = true
}
} else if (project.key == 'ST') {
if (actionName == 'Done') {
sampleList.hidden = true
}
}
Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
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.
Hi @Ram Kumar Aravindakshan _Adaptavist_
Im looking to the similar issue,
I have one query, for eg,
If issue is created based on one select list, I need the field to be populated on selection of option in select list field (when its created)
I have updated the fields in the screen which needs to be populated
and also created a behaviour with condition that
if request type = xx (when creation)it should display the category field in the transition. If not category field should be hidden. ( with condition as when workflow step: Resolved)
But this is not working as expected. Do I need any changes to be done for this
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.