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
Why is the first parameter APKeys.JiraIndexConfiguration.Issue?
It should be Issue object.
You are absolutely right.
I tried that and got success.
Thanks for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually I was using APKeys.JiraIndexConfiguration.Issue.
But i tried with Issue object and got Success.
Thank you so much for your inputs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the latest versions use GenericTextCFType instead of TextCFType.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which method I need to override if I use GenericTextCFType?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same getVelocityParameters method. Override the method first and then start working in it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes the above code should work. where you are getting the above mentioned error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the method is getVelocityParameters(...) if I am not wrong. Just check
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are right, the name is getVelocityParameters(...).
I tried that one also and got the same error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.