Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
titleAccessing Extra Option Information for Single/Multi Select Fields
import com.deniz.jira.cf.imp.ss.*;
import com.onresolve.scriptrunner.runner.customisers.PluginModule;
import com.onresolve.scriptrunner.runner.customisers.WithPlugin;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue;
import java.text.SimpleDateFormat;
import com.atlassian.activeobjects.external.ActiveObjects
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.atlassian.jira.issue.customfields.option.*;
import com.deniz.jira.cf.imp.message.*;
import org.apache.log4j.Logger
import org.apache.log4j.Level


//Set Log level for Debugging  
def log = Logger.getLogger("com.onresolve.jira.groovy")
log.setLevel(Level.DEBUG)
  

//Nasty Hack for Creating ExtraOptionInformationManagerFactory, because we don't export it yet
@WithPlugin("com.deniz.jira.customfields")
@PluginModule
MessageConfigManager messageConfigManager;
def activeObjects = ((MessageConfigManagerImp) messageConfigManager).activeObjects;

@WithPlugin("com.deniz.jira.customfields")
ExtraOptionInformationManagerFactory factory;
= new ExtraOptionInformationManagerFactory(activeObjects)
def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager)

def issue = event.issue as Issue;
 
def customersCF = customFieldManager.getCustomFieldObjectByName("Customers");
def customFieldValue = issue.getCustomFieldValue(customersCF); //this returns an array com.atlassian.jira.issue.customfields.option.Option
def fieldConfig = customersCF.getRelevantConfig(issue);
def extraOptionInformationManager = factory.get(customersCF, fieldConfig, true);

customFieldValue.each { option -> 
  def extraInfo = extraOptionInformationManager.getOption(((Option) option).getOptionId()); //ExtraOptionInformation
  log.debug("Description:" + extraInfo.getDescription());
}


...