costumed field type based on query result

kerensho December 27, 2020

Hi  all,

I'm trying to create a costumed field which presents a list of the sprints in the project. (similar to the "Sprint" built-in field, but for different purpose).

since there's no "sprint picker" type - is there a way to use an app (script runner for example) to base a field type on query result?

Thanks in advanced

2 answers

0 votes
Nic Brough -Adaptavist-
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.
December 28, 2020

I can't think of a use for a field like this.  Fields belong to issues and you already have the sprint field on issues, so this field would not be adding anything. 

Could you explain what you are trying to achieve for the end users?  

kerensho December 28, 2020

Hi Nic,

yes, sure, we want to use this feild for shared resource allocation, so one sprint field would be used to set the "desired" sprint, and the other sprint field (the built-in sprint field ) we'll be used to set the actual sprint.

Nic Brough -Adaptavist-
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.
December 28, 2020

I don't understand how that would be of any use.  If you have a "desired sprint", put the issue into it, that's what they're there for.

Resources are not allocated to issues, they are part of a team, and the team sees sprints from their board.

0 votes
Vladislav Bykouski December 28, 2020

Hi @kerensho 

Please check this documentation Select List Conversions 

You can create a select list field from a simple text field via behaviours+Rest End Point.

or by another way 

Put this code in Initialiser of Behaviours for your issue type

// you should provide list of sprint names for this method
void dynamicCreateOptions(List<String> sprintNames){
//get your field in behaviours style
def cf = getFieldByName("Sprints")
//get your field in Jira Api style
def cfObj= ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("Sprints")[0]
def fieldConfig = cfObj.getConfigurationSchemes()[0].configs.values()[0]
Map options = new HashMap()
for (String sprintName: sprintNames){
//try to find sprintName in existing options
def option = ComponentAccessor.optionsManager.getOptions(fieldConfig).find{ it.value==sprintName}
if (!option){
//creating a new option for custom field
ComponentAccessor.optionsManager.createOption(fieldConfig,0,1,sprintName)
def newfieldConfig = cfObj.getConfigurationSchemes()[0].configs.values()[0]
option = ComponentAccessor.optionsManager.getOptions(newfieldConfig).find{ it.value==sprintName}
}
options.put(option.getOptionId(),option.getValue())
}
//setting full list of options to form
cf.setFieldOptions(options.sort())
}
kerensho December 28, 2020

Thank you Vladislav, 

I'll sure try that

Suggest an answer

Log in or Sign up to answer