Java API for Multi Cascade
To use Multicascade Java API, you need to use an object of com.idalko.jira.plugins.igrid.api.data.MultiCascadeDataManager
 class. You can get it using the following code in your Groovy script:
Class dataManagerClass = pluginAccessor.getClassLoader().findClass("com.idalko.jira.plugins.igrid.api.data.MultiCascadeDataManager");
def tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(dataManagerClass);
MulticascadeDataManager has the following methods:
readMultiCascadeData method
@param customFieldId - the Multicascade's customfield ID
@param issueId - the ID of the relevant issue
@return a map that contains the multicascade's level name as the key and the respective selected value as the value
@throws MultiCascadeNotFoundException
@throws MultiCascadePermissionDeniedException
@throws MultiCascadeWrongCFTypeException
@throws MultiCascadeUserNotAuthorisedException
Map<String, String> readMultiCascadeData(Long customFieldId, Long issueId)
readMultiCascadeData example code
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.plugin.PluginAccessor;
import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger log = Logger.getLogger("com.idalko.scripts");
log.setLevel(Level.DEBUG);
// get an issue
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class);
Issue issue = issueManager.getIssueObject("TEST-1");
Long issueId = issue.getId()
// get Multicascade custom field
CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class);
CustomField multicascadeCustomField = customFieldManager.getCustomFieldObjectsByName("Multic").get(0);
Long multicascadeCustomFieldId = multicascadeCustomField.getIdAsLong();
// read Multicascadedata
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
// ScriptRunner could show a validation error at this point showing that the class could not be resolved.
// Just ignore it. It resolves it at the run time.
Class dataManagerClass = pluginAccessor.getClassLoader().findClass("com.idalko.jira.plugins.igrid.api.data.MultiCascadeDataManager");
def multicascadeDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(dataManagerClass);
StringBuilder result = new StringBuilder();
def resultMap = null;
try {
resultMap = multicascadeDataManager.readMultiCascadeData(multicascadeCustomFieldId, issueId);
result.append(resultMap.toString())
} catch (Exception e) {
log.debug("Multicascade ID=" + multicascadeCustomFieldId + " data cannot be retrieved: " + e.getMessage())
result.append("Multicascade ID=" + multicascadeCustomFieldId + " data cannot be retrieved: " + e.getMessage() + "\n");
}
return result.toString()