Forums

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

Best way to associate the custom fields only to particular projects

nallu August 12, 2019

We have around 700 projects in JIRA. In that, around 500 projects uses same Issue Type, Screen and Workflow schemes. We want to display a custom field only to 300 specific projects among 500. 

Is there any effective way to do that?

Currently, We have added the field to the screen which is globally used. And, we are controlling it through script runner behaviour. By default, the custom field will be hidden for all projects. In the Custom beehaviour script, we have hard-coded the  project keys to which the field should be visible. And, we are checking the project key in *IF* condition. If the condition is true, then we are overriding the default behaviour. 

Here is our script,

import com.atlassian.jira.project.Project

Project project = getIssueContext().getProjectObject()

String projectKey = project.getKey()

def feature_link_field = getFieldById('customfield_12345') // Defining an object for Feature Link issue

def projectKeys = ["AAAA","BBBB","CCCC","DDDD","TEST","FTHGYU","COLCRO","COLCS","COLCT","COLCW","COLCWA","COLDBRR","COLE","COLECPO","COLEE","COLEO","COLEP","COLET","COLFPI","COLFTE","COLHC","COLHVC","COLL","COLLS","COLP","COLPA","COLPAS","COLPAT","COLPDE","COLPE","COLPERA","COLPI","COLPLM","COLPOST","COLPP","COLPRAN","COLPS","COLRDD","COLRH","COLRIE","COLRNR","COLRPP","COLRR","COLRS","COLRULES","COLSEPLM","COLSM","COLTE","COLTIR","COLTRAIN","COLTX","COLUX","COLVZ","COLWA","COLWE","COLWMF","COMAA","CONAPI","CONINT","CONMGMT","COORDAUTO","COR","COSA","COSCH","CPDBEC","CPDC","CPDFEC","CPOR","CPS","CRP","CRZS","CSAM","CSBRAND","CSDBI","CSS","CSU","CSY","CT","CUSTSOL","CVB","DATAGOV","DATASEC","DCSS","DFOPS","DIRECT","DOCHUB","DPETL","DSCC","DSCOL","DSEE","DSF","DSINT","DSML","DSNDS","DSPL","DSRX","DSTTO","DTT","ECARE","ECFA","EDBI","EDF","EDIBI","EENG","EFHIR","EHPE","EICDTO","EICP","EIIT","EINT","EINTP","EIP","EMRIND","EPRSBE","ERCD","ERCDC","ERX","ESDS","ESI","ESORS","ETLAUTO","ETLAUTOBLR","ETLPD","GLOBPL","HCC","HCLCOG","HCLED","HCLEI","HCLIS","HCLN","HCLOW","HCLS","HCLSP","HCLT","HCLUX","HCOBP","HCOCIH","HCOGF","HCOI","HCOPCA","HCORDP","HCORS","HCOTC","HCPF","HOSPL","IAM","IDP","IMM","INTRPSVC","IOCLIN","IOCOL","ISAB","ISARCH","ISBCS","ISBI","ISCAPS","ISCONN","ISKM","ISMS","ISTESTAUTO","KMEG","MA","MCS","MDP","MDPBI","MDPM2","MEDS","MEHRI","MESACT","MMI","MMV","MNLP","MOM","MP","MSD","MVA","NGDA","NPO","NVSE","ORP","ORS","P2AB","P2AG","P2AM","P2AP","P2DI","P2DP","P2DXE","P2DXP","P2EDIP","P2FG","P2HOBJ","P2LS","P2MN","P2MS","P2NBCD","P2NDT","PAN","PAQE","PBI","PCCS","PCDI","PCLBI","PCM","PCPI","PCSO","PDAC","PDD","PDDC","PDFRB","PDFSA","PDM","PDO","PDOP","PEI","PHOPS","PHPM","PHRM","PIO","PIOCON","PLAMDP","PLATAC","PLATBI","PLATFC","PLATNDA","PLATRT","PLATSECR","PLAW","PLBKUP","PLFC","PNQS","POM","POPDP","POPGL","POPIM","POPOPS","POPPCA","POPSB","PPD","PPDS","PPO","PPSPA","PRAXDS","PRINT","PSCI","PSMG","PSPCC","PSPDA","PSPDEVO","PSPIOM","PSPIOPE","PSPIOW","PSPWF","PSQIR","PSUSA","PSW","PSWA","PTD","PTF","PWA","PXMAC","PXMMP","PZO","QMAASBI","QMAASREQ","QMAT","QMDA","QMDH","QMII","QMQRS","QPAPM","QRULES","RDP","REPAPI","RESCOUN","RESEARCH","RIDE","ROPS","RPA","RPRACM","RULESMOD","SDO","SEC","SECH","SECLINDOC","SECLORDERS","SECLTASKS","SECRT","SEPAE","SGD","SL","SMAB","SSDA","SUA","SWITCH","TEES","TGH","UIAMIACA","UIAMUA","UPEPWA","UTMC","UXDS","XDEM","XDGE","XRAYCOL"];


if (projectKeys.contains(projectKey))
{
feature_link_field.setHidden(false);
}

// End of the script;

 

We really don't want to control it this way as the list is just getting evolved. So, Please let me know if there is any effective way to do it. 

 

I have also tried with Profiled. But it did not help. I thought, I can write a behaviour script to get Profiled value and based on the value, i can set the property. But I could able to read the Profiled value in behaviour script. It always returns null. I have raised question on community for that too.

Here It is - https://community.atlassian.com/t5/Jira-questions/How-to-check-Profiled-value-in-script-runner-behaviour/qaq-p/1148405#M365808

 

 

2 answers

0 votes
Yevhen Rohovets
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2019

Really the only right option is to split configurations.
For projects with additional fields, a separate scheme is needed, for projects without these fields, a different one is needed.
I.e:
1) create a separate circuit that differs in configuration
2) apply a new scheme for the required fields

0 votes
Mohamed Benziane
Community Champion
August 12, 2019

Hi @nallu 

You need to use field configuration for those 300 project, and another field configuration for the other projects.

In the first field configuration i will show those custom field, and on the other one i will hide them. field configuration.

 

All you need to know about field configuration is here:

https://confluence.atlassian.com/adminjiracloud/adding-editing-and-deleting-a-field-configuration-844500796.html

https://confluence.atlassian.com/adminjiracloud/configuring-a-field-configuration-scheme-844500805.html

You can also juste change the screen scheme for these projects.

nallu August 12, 2019

Hi @Mohamed Benziane @Yevhen Rohovets 

Thanks for the quick response. I understand that having different field configuration will be the right solution. 

But In our case, It just a single custom field. We don't want to have two different field  configurations because of this one field. 

I m looking to the solution which will still allow me to use same screen , workflow and field configuration scheme. But also help me to achieve what i want. 

Please let me know if there is any script runner solution or help me to find out why i couldn't read profield value from script runner behaviour. 

thanks so much!! 

Mohamed Benziane
Community Champion
August 12, 2019

Hi @nallu 

You can use Behaviour, and display this custom field only for the project you want.

Behaviour come with scriptrunner addon.

 

Hope this helps

Suggest an answer

Log in or Sign up to answer