Forums

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

I need to create 3 new custom field types. Can someone help?

Chad
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 19, 2018

I have recently finished the tutorial on how to create a basic Jira plugin and have started experimenting with creating new custom field types.

Currently using this documentation:

https://developer.atlassian.com/server/jira/platform/creating-a-custom-field-in-jira/
https://developer.atlassian.com/server/jira/platform/custom-field/

Our team has a need to create three new custom field types that do not store any data in the history/change logs.

1. A New Custom Text Field type

2. A New Custom Date/Time Field type

3. A New Custom Number Field type

It is also a requirement that these fields must be searchable.

So far I have been successful in creating the custom text field (not sure how to make it searchable), but the number and date/time fields are proving to be a struggle.

Here is the code I have for the text field:

import com.atlassian.jira.issue.customfields.impl.GenericTextCFType;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.TextFieldCharacterLengthValidator;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.JiraImport;

@Scanned
public class TextCustomField extends GenericTextCFType {

public TextCustomField(
@JiraImport CustomFieldValuePersister customFieldValuePersister,
@JiraImport GenericConfigManager genericConfigManager,
@JiraImport TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,
@JiraImport JiraAuthenticationContext jiraAuthenticationContext) {
super(customFieldValuePersister, genericConfigManager, textFieldCharacterLengthValidator , jiraAuthenticationContext);
}

@Override
public String getChangelogValue(CustomField field, String value) {
// No log into history tab
return null;
}
}

Any advice for creating the other two field types would be greatly appreciated!

Thanks! 

1 answer

1 accepted

0 votes
Answer accepted
Chad
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 29, 2018

Using the JIRA source code as a guide has helped me to get most of this done. I was able to pull the TextCFType.java, NumberCFType.java, and DateTimeCFType.java files from it along with the corresponding searcher classes. 

https://my.atlassian.com/download/source/stash

I still haven't figured out how to get the searcher working for the Date/Time field because maven dependencies are a pain and the public Jira API doesn't seem to include all of the necessary class imports. If anyone has a good solve for this I'd love to hear it.

Suggest an answer

Log in or Sign up to answer