You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi I am trying to create a behaviour to show a custom field based on component value.
I have read the previous helpful articles and have the following script
def comp = getFieldById(COMPONENTS)
def values = comp.getValue()*.getName()
def tatr = getFieldById('customfield_14310')
tatr.setHidden(true)
if(values.toString().contains("test"))
{
tatr.setHidden(false)
}
This shows a spread operator error on line 2 (def values) and hides the custom field no matter what.
Can someone give me a hint what could be wrong?
Thanks
I've modified the script slightly , I haven't tested this out by myself so may require some changes
import com.atlassian.jira.bc.project.component.ProjectComponent
def component = getFieldById(getFieldChanged())
def tatr = getFieldById('customfield_14310')
List <ProjectComponent> comps = component.getValue() as List
def isthere = false
tatr.setHidden(true)
for(c in comps){
if(c.getName().contains("test")){isthere = true}
}
if(isthere){
tatr.setHidden(false)
}
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've tested below script and it's working, no modifications required
you'll have to place this script as server side script for Component/s field
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def tatr = getFieldById('customfield_14310')
def components = getFieldById(getFieldChanged()).getValue() as List<ProjectComponent>
tatr.setHidden(!components.any {it.name.contains("test")})
BR,
Leo
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.
@Leo Is it possible to leave the component/s field which is a mandatory field system, via scriptrunner?
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.