Hi Everyone,
I have a custom plugin/events listener that I am rewriting to support JIRA 5.
but I am getting an exception , can anyone help fix this, or show a sample of how to get values from cascading select field using JIRA 5 SDK.
JIRA 4:
{code}
Issue currentIssue = event.getIssue();
IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
MutableIssue mutIssue = issueManager.getIssueObject(currentIssue.getKey());
CustomFieldManager cfm = ComponentManager.getInstance().getCustomFieldManager();
CustomField customField = ManagerFactory.getCustomFieldManager().getCustomFieldObjectByName("MyCascadeSelect");
CustomFieldParamsImpl params = (CustomFieldParamsImpl) currentIssue.getCustomFieldValue(customField);
LazyLoadedOption option1 = (LazyLoadedOption) params.getFirstValueForNullKey();
LazyLoadedOption option2 = (LazyLoadedOption) params.getFirstValueForKey("1");
String value1 = option1.getValue();
{code}
JIRA 5
{code} Issue currentIssue = event.getIssue();
IssueManager issueManager = ComponentAccessor.getIssueManager();
MutableIssue mutIssue = issueManager.getIssueObject(currentIssue.getKey());
CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MyCascadeSelect");
// System.out.println(customField.getCustomFieldType().getName()); //cascading select
// System.out.println(currentIssue.getCustomFieldValue(customField).getClass().getName()); //HashMap
HashMap value = (HashMap)currentIssue.getCustomFieldValue(inRegardsTo);
// System.out.println(value.size()); //2
// System.out.println(value.values().toArray()[0].getClass().getName()); // LazyLoadedOption
CustomFieldParamsImpl params = (CustomFieldParamsImpl) currentIssue.getCustomFieldValue(customField); // exception :
// java.lang.ClassCastException: java.util.HashMap cannot be cast to com.atlassian.jira.issue.customfields.view.CustomFieldParamsImpl
{code}
Community moderators have prevented the ability to post new answers.
here is the solution to share :
LazyLoadedOption option1 = (LazyLoadedOption) params.getFirstValueForNullKey();
will become
LazyLoadedOption option1 = (LazyLoadedOption) value.values()toArray()[0];
thank you very much, I just used your solution and it worked well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am glad this is helpful for other users ..I need to resolve this question and my second comment is the right answer.
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.