error: 'java.lang.NullPointerException - null' while creating custom field type in jira

I want to use following method for creation of custom field. But I am getting null pointer exception so I think the error is because of  FieldConfig fc=field.getRelevantConfig(issue); If this is correct then why I am getting that error and if not then can anyone help me because of which I am getting an error?

@Named("SelectCF")

public class SelectCF extends GenericTextCFType

{

@ComponentImport

private final UserManager um;

@ComponentImport

private final JiraAuthenticationContext jac;

@ComponentImport 

private final CustomFieldValuePersister customFieldValuePersister;

@ComponentImport 

private final GenericConfigManager genericConfigManager;

@ComponentImport 

private final TextFieldCharacterLengthValidator textFieldCharacterLengthValidator;

@ComponentImport

OptionsManager omm;

@Inject

    public SelectCF(CustomFieldValuePersister customFieldValuePersister, GenericConfigManager genericConfigManager,JiraAuthenticationContext jac ,TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,UserManager um ,OptionsManager omm)

    {

    super(customFieldValuePersister, genericConfigManager,textFieldCharacterLengthValidator,jac);

    this.customFieldValuePersister=customFieldValuePersister;

        this.genericConfigManager=genericConfigManager;

 this.textFieldCharacterLengthValidator=textFieldCharacterLengthValidator;

        this.omm=omm;

        this.jac=jac;

        this.um=um; 

    }    

public Map<String, Object> getVelocityParameters(final Issue issue,
final CustomField field,
final FieldLayoutItem fieldLayoutItem)
{
final Map<String, Object> map = super.getVelocityParameters(issue, field, fieldLayoutItem);

int num=0;
int num1=1;
FieldConfig fc=field.getRelevantConfig(issue);
Options options=ComponentAccessor.getComponent(Options.class);

Option op1=omm.createOption(fc, null, new Long(num), "Hello");
Option op2=omm.createOption(fc, null, new Long(num1), "World");

options.add(op1);
options.add(op2);
map.put("option1", "Hello");
map.put("option2", "World");

return map;
}

}

0 answers

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,772 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot