Getting error while using TextCFType for custom field

I am trying to develop a custom field using below Java code :


public class ReadOnlyUserCF extends TextCFType{ private final JiraAuthenticationContext authContext; public ReadOnlyUserCF(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter, GenericConfigManager genericConfigManager, JiraAuthenticationContext authContext) { super(customFieldValuePersister, stringConverter, genericConfigManager); this.authContext = authContext; } @Override public Map getVelocityParameter(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem){ Map params = super.getVelocityParameters(issue, field, fieldLayoutItem); params.put("currentUser", authContext.getLoggedInUser().getName()); return params; } }

But I am getting below error :

The method getVelocityParameter(APKeys.JiraIndexConfiguration.Issue, CustomField, FieldLayoutItem) of type ReadOnlyUserCF must override or implement a supertype method.

Also TextCFType is showing deprecated.

Please share your knowledge.

Thanks

5 answers

1 accepted

0 votes
Accepted answer

Why is the first parameter APKeys.JiraIndexConfiguration.Issue?

It should be Issue object.

yes the above code should work. where you are getting the above mentioned error?

I am getting error on getVelocityParameter.

The error is:

The method getVelocityParameter(APKeys.JiraIndexConfiguration.Issue, CustomField, FieldLayoutItem) of type ReadOnlyUserCF must override or implement a supertype method

the method is getVelocityParameters(...) if I am not wrong. Just check

You are right, the name is getVelocityParameters(...).

I tried that one also and got the same error.

public class ReadOnlyUserCF extends TextCFType{

private final JiraAuthenticationContext authContext;

public ReadOnlyUserCF(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter,

GenericConfigManager genericConfigManager, JiraAuthenticationContext authContext) {

super(customFieldValuePersister, stringConverter, genericConfigManager);

this.authContext = authContext;

}

@Override

public Map getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem) {

Map params = super.getVelocityParameters(issue, field, fieldLayoutItem);

params.put("currentUser", authContext.getUser().getName());

return params;

}

}

this code(which exactly mentioned by you in the question except getVelocityParameters name) is working for me.

I could able to compile it properly with no errors.

Also the import statement for Issue should be

import com.atlassian.jira.issue.Issue;

# The same getVelocityParameters(Issue issue,CustomField field, FieldLayoutItem fieldLayoutItem) you need to override even you use GenericTextCFType

hope this should solve your problem

0 votes

In the latest versions use GenericTextCFType instead of TextCFType.

Which method I need to override if I use GenericTextCFType?

Same getVelocityParameters method. Override the method first and then start working in it.

I tried that one but getting below error:

The method getVelocityParameters(APKeys.JiraIndexConfiguration.Issue, CustomField, FieldLayoutItem) of type ReadOnlyUserCF must override or implement a supertype method

Actually I was using APKeys.JiraIndexConfiguration.Issue.

But i tried with Issue object and got Success.

Thank you so much for your inputs.

You are absolutely right.

I tried that and got success.

Thanks for your help.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,717 views 17 21
Read article

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