import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.CustomFieldManager; int sumCustomFieldValues( string customFieldId) { int sum = 0 ; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField customField = customFieldManager.getCustomFieldObject(customFieldId); if(issue .getCustomFieldValue(customField)!=null){ sum = 1; } return sum; } sumCustomFieldValues("customfield_ 10003" ); Question: This code works fine. Customfield_10003 is a select list, how can I get the selected value/Index?
I am using JIRA 5.1 download.
|
Community moderators have prevented the ability to post new answers.
Option selectedVal = (Option) issue.getCustomFieldValue(customField); String val = selectedVal.getValue();
Unfortunately, I tried your code, and val is null.
Option selectedVal = (Option) issue.getCustomFieldValue(customField);
String val = selectedVal.getValue();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have some value selected on the issue? And make sure the customfield is the select field itself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I did select a value for it. The original code does not work either. TOO BAD
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't make it work anyway. I am using a plug-in(Misc Custom Field) and create a Calculated Number Field. I tried to put those code inside this field description with below syntax:
<!-- @ @Formula : formula goes here --> |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This question was marked answered but it's not clear that it was actually answered. What was the solution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Option selectedVal = (Option) issue.getCustomFieldValue(customField);
String val = selectedVal.getValue();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
// gets a reference to the IssueManager and CustomFieldManager manager classes
final CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
// gets a reference to the desired custom field
final CustomField customField = customFieldManager.getCustomFieldObjectByName("custom-field-name");
// retrieves the custom field value object from the issue
final Object customFieldValue = issue.getCustomFieldValue(customField);
// prints value to console
System.out.println("Custom field value: " + customFieldValue);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your code does not work if there are several custom fields with same name in different projects and they do not share configuration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then use the field's ID (which is String) and call: com.atlassian.jira.issue.CustomFieldManager.getCustomFieldObject(String)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
How to create customfieldmanager for particular issue .
i want to fetch the customfieldobject of particular issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try using in the above code -
FieldConfig fieldConfig = customFieldManager.getRelevantConfig(issue); List<Option> option = ComponentAccessor.getOptionsManager().findByOptionValue("option");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, Naren.
List<Option> option = ComponentAccessor.getOptionsManager().findByOptionValue(
"option"
);
But I still not get it. This will return a list of options. How can I get the selected option???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.