Hi all,
I like to select a entry of a customfield from type of Select List.
Since Jira 4.4 the the way I updated the customfield didn't work any more for a Select List or Mult Select List.
{code}
final CustomFieldManager cfManager = ComponentManager
.getInstance().getCustomFieldManager();
final CustomField cf = cfManager
.getCustomFieldObjectByName(sCustomField_Name);
final IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
cf.updateValue(null, issue,
new ModifiedValue(
issue.getCustomFieldValue(cf),
oCustomField_Value),
changeHolder);
{code}
I read some articles about this behaviour, but thy handle about adding or sorting options.
But I want "only" select one existing option by programm (in a plugin).
Has someone a code snippet to demonstrate how to handle this problem?
Thanks
Uli
Community moderators have prevented the ability to post new answers.
What is oCustomField_Value? Is it an Option object?
The oCustomField_Value is java.lang.Object
public static void updateCustomField(final Issue issue,
final String sThisClass, final String sCustomField_Name,
final Object oCustomField_Value)
Should it be an Option Object?
If yes, how can I get one? And how to handle it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I changed the oCustomFieldValue to type "Option" and it works.
My problem was to figure out how to get the Option.
The following code-snipped shows how I solved it (I hope it can help other member of the community):
final CustomFieldManager cfm = ComponentManager.getInstance().getCustomFieldManager(); final CustomField customField = cfm.getCustomFieldObjectByName("myCustomField"); final OptionsManager optionsManager = ComponentAccessor .getOptionsManager(); final FieldConfig fieldConfig = customField .getRelevantConfig(issue); final Options options = optionsManager.getOptions(fieldConfig); final Option oTaskTypeOption; String sTaskType = "mySelectListEntry"; oTaskTypeOption = options.getOptionForValue(sTaskType, null); final CustomFieldManager cfManager = ComponentManager.getInstance().getCustomFieldManager(); final CustomField cf = cfManager.getCustomFieldObjectByName(sCustomField_Name); final IssueChangeHolder changeHolder = new DefaultIssueChangeHolder(); cf.updateValue(null, issue,new ModifiedValue(issue.getCustomFieldValue(cf),oTaskType), changeHolder);
Thanks Jobin, you sent me to the right way
Uli
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.