Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Aisha M
Contributor
October 19, 2020

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 Champion
October 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

Aisha M
Contributor
October 20, 2020

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

Vikrant Yadav
Community Champion
October 20, 2020

@Aisha M 

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

 

if (issuetype.contains("Story")) {
fieldToHide.setHidden(false)
}
Aisha M
Contributor
October 20, 2020

@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 Champion
October 20, 2020

Hi @Aisha M 

You need to do the mapping of the Project in Behaviour

 

Capture.PNG

Aisha M
Contributor
October 20, 2020

@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

Morten Stensgaard
Contributor
November 29, 2022

@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