Hi all,
I have a workflow with screens on Start progress and Resolve and two issue types (Incident and Service request) linked with this workflow.
On these screens there is a field "Incident affected" which is not needed for Service request issues.
Now I want to hide this field with "Behaviours" for all issues with Service request issue type and for Incidents, if priority is lower than Medium. current variants in conditions are inappropriate for this case.
maybe there is a way to make an advanced searching issues with jql in Behaviours?
You can achieve this by using the underlyingIssue binding in an initialiser script for the behaviour like below:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.config.PriorityManager import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript @BaseScript FieldBehaviours fieldBehaviours // this is issue create and we have no underlying issue yet if (! underlyingIssue) { return } def issueTypeName = underlyingIssue.getIssueTypeObject().getName() def priortityManager = ComponentAccessor.getComponent(PriorityManager) // get medium priority def mediumPriority = priortityManager.getPriorities().find { priority -> priority.name == "Medium" } // the higher the priority sequence number the lower the priority if (issueTypeName == "Service request" || (issueTypeName == "Incident" && underlyingIssue.priorityObject.sequence > mediumPriority)) { def incidentField = getFieldByName("Incident affected") incidentField.setHidden(true) }
JQL is not really well suited to this as you would need to search through all the issues when you already have the issue available here, its not very feasible as it needs to run every time someone views a page.
Hope this helps,
Adam
Thanks, Adam!
it must be added to "Add serverside script", isn't it?
can we set some value for "Incident affected" (it is a single choise select list) here in this script or it have to be done from the workflow transition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes thats correct, it should be added to the initialiser like in this example: https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_setting_a_default_description
Theres an example for setting a default value for the select list here: https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_setting_a_default_description
But if you don't want the user to edit this default selected value you also need to add:
incidentField.setReadOnly(true)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
added this lines (needed to set a value by default when it's hidden), it works correctly.
thanks a lot!
def IncidentAffected = getFieldByName("Incident Affected") int defaultVal = 10404 //single user IncidentAffected.setFormValue(defaultVal)
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.