Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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
Published in Marketplace Apps & Integrations

Learn how to request and manage app requests in the Marketplace

G’day everyone! Super exciting news coming from the Marketplace. We have now fully rolled out the ability for end-users to submit app requests to admins directly from within the product! No longer ...

43 views 1 5
Read article

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