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

Plugin-Development: Filling a SelectCFType (select list) with options

Arthur Dent August 6, 2012

Hello,

I want to develop a custom field (select list) which is prefilled with some data according to the logged-in user. I successfully read and deployed the CustomField tutorial here: https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Creating+a+Custom+Field+in+JIRA

but now I am struck with extending the field to my needs. What I have so far is:

public class MoneyCustomField extends SelectCFType {
	
	public MoneyCustomField(
			CustomFieldValuePersister customFieldValuePersister,
			StringConverter stringConverter, SelectConverter selectConverter,
			OptionsManager optionsManager,
			GenericConfigManager genericConfigManager) {
		
		super(customFieldValuePersister, stringConverter, selectConverter,
				optionsManager, genericConfigManager);
		
                //where do I get these parameters ?!?
               optionsManager.createOption(arg0, arg1, arg2, arg3)
		
	
	}

The question is where to get the parameters for the createOptions method from?

[createOption(FieldConfig fieldConfig, Long parentOptionId, Long sequence, String value) ]

If you know any example plugin which uses a SelectCFType you can also name it..I can read and program Java, I just don't know about how to access all of Jiras features.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
SRIDHAR August 20, 2012

Are you able to solve the issue ? I need code sample . I need to write a custom plugin for a select list for my customization.

0 votes
Andrew Pechnikov
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 15, 2012

createOption(FieldConfig fieldConfig, Long parentOptionId, Long sequence, String value)

-FieldConfig fieldConfig = field.getRelevantConfig(issue);

-parentOption ID takes value only for cascading select list

-You may set sequense long(0), tht's not really matter

-value - that's your value you want option to take


0 votes
Michael Danielsson
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 6, 2012

I have used this cod in one of my plugins

public Option addOptionToCustomField(CustomField customField, String value) {
		Option newOption = null;

		if (customField != null) {
			List<FieldConfigScheme> schemes = customField
					.getConfigurationSchemes();
			if (schemes != null && !schemes.isEmpty()) {
				FieldConfigScheme sc = schemes.get(0);
				Map configs = sc.getConfigsByConfig();
				if (configs != null && !configs.isEmpty()) {
					FieldConfig config = (FieldConfig) configs.keySet()
							.iterator().next();

					OptionsManager optionsManager = getOptionsManager();
					Options l = optionsManager.getOptions(config);
					Option opt;

					int numberAdded = 100;
					newOption = optionsManager.createOption(config, null,
							new Long(numberAdded), 
							value);
				}
			}
		}

		return newOption;
	}

I think

int numberAdded = 100;
is used to order the options and it should probably be different for each option but it worked.

SRIDHAR August 20, 2012

where do i need to call the addOptionToCustomField method ? I need help to write a select list plugin.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events