Forums

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

How to use one custom field to two different issuetype with different values on same project?

Dharnesh July 4, 2019

We have a custom field (Single list-Single select) with 10 values(ex- a,b,c,d,e,f,g,h,i,j)

Now would like to use this custom field on creating two different issue-type(A, B) on same project.

But while creating issue-type (A). We need values to be displayed only(a,b,c,d,e) 

and while creating issue-type (B). We need values to be displayed only(f,g,h,i,j)


knowing this is not possible using custom configure. which would end up creating two field of same type and name.

Wanted to check whether this is possible through behavior? Could someone please suggest. How to proceed in this?  

2 answers

1 accepted

0 votes
Answer accepted
Dharnesh July 11, 2019

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()


def selectList = getFieldById("customfield_18736")


def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

 

if (issueContext.issueType.name == "Ambulatory Change Control") {

def optionsMap = options.findAll {
it.value in ["Maintenance", "Configuration", "Migration", "Enhancement", "Domain Wide Update", "Custom Build", "New Build", "None"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)



} else{

def optionsMap = options.findAll {
it.value in ["Normal", "Emergency", "None"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)

}

Dharnesh July 11, 2019

This help me to achieve....!

0 votes
Alexey Matveev
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.
July 4, 2019

Hello,

It is not possible in Cloud. 

Dharnesh July 4, 2019

Not using cloud. Please let me know is it possible on local.

Alexey Matveev
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.
July 4, 2019

You would need an app for it like Power Scripts or ScriptRunner.

If you want to use the Power Scripts app, you can find a tutorial here:

https://confluence.cprime.io/display/TR/Restrict+a+select+list+to+not+show+certain+values

Dharnesh July 4, 2019

Thanks. Let me try it out

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events