Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,936
Community Members
 
Community Events
176
Community Groups

Need help with Behaviour to be enabled for few project from "All Projects"

I have the below sample code. I want to enable a field to few projects (3) out of "ALL PROJECTS"(100)  selection from the mapping list. How do I mention the field to be available only for a few projects in the script?

import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

final String fieldName = 'TextField'

// get field by name and hide it
getFieldByName(fieldName).setHidden(true)

1 answer

0 votes
Vikrant Yadav Community Leader Oct 20, 2020

Hi @Aisha M

You can do this using Custom Field > Search Field > Configure , select only those project in which you want this field to appear, or via field behavior you need to map only 3 project in which you want this field to appear. No need to write script

@Vikrant Yadav  Thank you for the reply. Yes I m aware of that. I m looking at using Behaviours specifically. 

Vikrant Yadav Community Leader Oct 20, 2020

@Aisha M 

In behavior also , you can hide the field using behaviour  :-

 

if (issuetype.contains("Story")) {
fieldToHide.setHidden(false)
}

@Vikrant Yadav Thanks you. How do I ensure the behaviour doesnt hide the field to a few number of projects alone ? Like, I have 100 projects & want the field to be visible in only a few alone. How to call that from the script.

Under Mapping, I want to specify "ALL PROJECTS" , then in the server-side script, I want to exclude the hiding of fields for a few projects alone from the list of "ALL PROJECTS". 

Vikrant Yadav Community Leader Oct 20, 2020

Hi @Aisha M 

You need to do the mapping of the Project in Behaviour

 

Capture.PNG

@Vikrant Yadav Yes. But the problem is I have close to 200 for the field to be hidden & field available for maybe 6. So, we don't want to manually select 200 projects to hide the field. Hence looking for ways to select all projects at the mapping step & then mention the 6 projects alone for which the field should be available from the script.

So basically,

In Mapping - "ALL PROJECTS"

In script - Keep the field hidden for ALL PROJECTS except for the 6

Hope I made sense

@Aisha M Did you find a solution to this? - I'm also searching for a way to invert/except specific projects/issues types from a behaviour.

 

Ex. Hide Time Tracking for ALL PROJECTS except 3 projects.

Suggest an answer

Log in or Sign up to answer