Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ScriptRunner:com.decadis.jira.xchart.api.model.Period, check the plugin is installed / enabled / lic


Hi Dear All:

I met a difficult when i run my script in the ScriptRunner , This Problem makes me puzzled in the past two days, if there somebady can solve this problem, please make me know, Thanks.


Script console script failed: java.lang.Exception: Can't find plugin module or OSGi service for class: com.decadis.jira.xchart.api.model.Period, check the plugin is installed / enabled / licensed.

JIRA Version:8.2.1                       ScriptRunner Version:


You can find the API in



import java.lang.reflect.Field;

import java.math.BigDecimal;
import java.util.Date;

import org.apache.lucene.document.Document;

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.DocumentIssueImpl;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueFieldConstants;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.FieldManager;
import com.atlassian.jira.jql.builder.JqlClauseBuilder;
import com.atlassian.jira.jql.builder.JqlQueryBuilder;
import com.atlassian.jira.jql.parser.JqlQueryParser;
import com.atlassian.query.Query;
import com.atlassian.query.operator.Operator;
import com.atlassian.jira.jql.parser.JqlParseException
import com.atlassian.jira.user.ApplicationUser

import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.decadis.jira.xchart.api.util.ChartBuilder
//import com.decadis.jira.xchart.api.ChartParam;
import com.decadis.jira.xchart.api.model.Period;
import com.decadis.jira.xchart.api.util.DateUtils;


Period period

ChartBuilder chartBuilder

DateUtils dateUtils

def DateFieldParam="created";
def TimePeriod="DAY";
def ValuePicker="issueCount";
def GroupBy="resolution";
def From="-14d";
def JQL="project = OCC AND resolution = Unresolved";
def ChartType="bar";

def fieldManager = ComponentAccessor.getFieldManager();
def i18n = ComponentAccessor.getJiraAuthenticationContext().getI18nHelper();

String dateField = DateFieldParam;
if ( dateField.isEmpty() )
dateField = IssueFieldConstants.CREATED;

com.atlassian.jira.issue.fields.Field dateFieldObject = fieldManager.getField(dateField);
boolean isCustomField = fieldManager.isCustomField(dateFieldObject);
Period selectedPeriod = period.fromString(TimePeriod);

JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class);
Query query = null;

JqlClauseBuilder jqlClauseBuilder = JqlQueryBuilder.newClauseBuilder(jqlQueryParser.parseQuery(JQL));

Date start = chartBuilder.getDateFromParam(From);

String searchKey = dateFieldObject.getId();
if ( isCustomField ) {
searchKey = "cf[" + ((CustomField) dateFieldObject).getIdAsLong() + "]";

if ( start != null ) {
jqlClauseBuilder.addDateCondition(searchKey, Operator.GREATER_THAN_EQUALS, start);

query = jqlClauseBuilder.buildQuery();


def countGroup = chartBuilder.newDataCollector();
def valueExtractor = chartBuilder.getValueExtractor(ValuePicker);

if ( valueExtractor == null )
throw new IllegalArgumentException("Valuepicker for " + ValuePicker + " is not supported.");

def groupValueExtractor = chartBuilder.getGrouper(GroupBy);
Field documentField;
documentField = DocumentIssueImpl.class.getDeclaredField("document");

for ( Issue issue : chartBuilder.getFilterUtils().performSearchOverrideSecurity(query) )
Document document = (Document) documentField.get(issue);
String[] groups = groupValueExtractor.getGroups((Document) documentField.get(issue));

for ( String group : groups )
Date dateFromField = new Date();
if ( isCustomField ) {
dateFromField = (Date) issue.getCustomFieldValue((CustomField) dateFieldObject);
switch ( dateFieldObject.getId() ) {
case IssueFieldConstants.CREATED:
dateFromField = issue.getCreated();
case IssueFieldConstants.UPDATED:
dateFromField = issue.getUpdated();
case IssueFieldConstants.RESOLUTION_DATE:
dateFromField = issue.getResolutionDate();
case IssueFieldConstants.DUE_DATE:
dateFromField = issue.getDueDate();
dateFromField = new Date();
countGroup.addValue(valueExtractor.get(issue, document), group, dateUtils.getPeriodGroup(dateFromField, selectedPeriod));
} catch (Exception e) {
System.out.println("Could not extract groups" + e);


def chartData = chartBuilder.newChartData(i18n.getText("common.concepts.issues"));

for ( String grpKey : countGroup.keySet() )
chartData.addGroupName(grpKey, groupValueExtractor.getResolvedValue(grpKey, null));



chartBuilder.getChartUtil().transformResult(countGroup, chartData, true);
return chartData;





0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

217 views 0 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you