We are upgrading jira 6.3.9 to Jira 7.0.0

Hello,

We are upgrading jira 6.3.9 to Jira 7.0.0.

The groovy script we are using for Jira 6.3.9 is not working in jira 7.0.0.

The groovy script that we are using in JIRA 6.3.9 has methods that are not supported in JIRA7.0.0 it seems.

For example : getCustomFieldManager(). PFA snapshot for reference.

Is there any documentation or URL to get all changed methods and implementations from 6.3.9 to 7.0.0? Please provide us.

Please find script we are using as below.


import com.atlassian.jira.ComponentManager
import org.apache.log4j.Category
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.util.JiraUtils
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.issue.comments.CommentManager
import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.ParseException;

def Category log = Category.getInstance(“com.onresolve.jira.groovy.PostFunction”)
log.setLevel(org.apache.log4j.Level.DEBUG)
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager cManager = ComponentManager.getInstance().getCustomFieldManager()
def String adminUserName = “t_thakn”
String currentUser = ((WorkflowContext) transientVars.get(“context”)).getCaller();
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
log.debug("adminUserName " + adminUserName)
log.debug("currentUser " + currentUser)
def cf = cManager.getCustomFieldObject(10103)
def cust = cManager.getCustomFieldObject(10300)
def String activitytype = “”
def String formtype = “”
def String finalformtype = “”
def String finalactivitytype = “”
def String subactivitytype = “”

UserManager userMan = ComponentAccessor.getUserManager()
IssueManager issueManager = componentManager.getIssueManager()

def String status = issue.getStatusObject().getName()
activitytype = issue.getCustomFieldValue(cf)

formtype = issue.getCustomFieldValue(cust)
log.debug(“formtype is = " + formtype.toString())
if (formtype != null) {
finalformtype = formtype.substring(formtype.indexOf(”=") + 1, formtype.indexOf(",")).trim()
}
log.debug("final form type = " + finalformtype)
log.debug("activitytyep**************** " + activitytype)
if (activitytype != null) {

finalactivitytype = activitytype.substring(activitytype.indexOf("=") + 1, activitytype.indexOf(",")).trim()
subactivitytype = activitytype.substring(activitytype.indexOf(“1=”) + 2, activitytype.indexOf("}")).trim();
}

def String parentStatus = issue.getParentObject().getStatusObject().getName()
log.debug("parent Status —> " + parentStatus)

if (issue.getParentObject().getStatusObject().getName() == ‘Approved’ || issue.getParentObject().getStatusObject().getName() == ‘Live’) {
log.debug("child Status —> " + issue.getStatusObject().getName())
if (issue.getStatusObject().getName() == ‘Draft’) {
if (activitytype != null) {
if (subactivitytype.toString().indexOf(“Direct Mail”) < 0) {
if (finalactivitytype.toString().indexOf(“Email Direct”) < 0) {
if (finalactivitytype.toString().indexOf(“Targeted Campaigns”) < 0) {
if (finalactivitytype.toString().indexOf(“Data Upload”) < 0) {
if (finalactivitytype.toString().indexOf(“Telemarketing”) < 0) {
if (finalactivitytype.toString().indexOf(“Data Enrichment”) < 0) {
if (finalactivitytype.toString().indexOf(“New List Acquisition”) < 0) {
workflowTransitionUtil.setIssue(issue)
workflowTransitionUtil.setUsername(adminUserName)
workflowTransitionUtil.setAction(31) // 31 == APPROVED
workflowTransitionUtil.validate()
workflowTransitionUtil.progress()
log.debug(“Activity Approved”)
def date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd”);
String currentDate = dateFormat.format(date);
Date convertedToDate = dateFormat.parse(currentDate);
log.debug(“before date set”);
java.sql.Date sql = new java.sql.Date(convertedToDate.getTime());
cf = cManager.getCustomFieldObject(13500)
issue.setCustomFieldValue(cf, sql);
log.debug(“date is setting here inside draft to submitted”)
}
}
}
}
}
}
}

} else if (formtype != null) {
if (finalformtype.toString().indexOf(“Web Form”) < 0) {
workflowTransitionUtil.setIssue(issue)
workflowTransitionUtil.setUsername(adminUserName)
workflowTransitionUtil.setAction(31) // 31 == APPROVED
workflowTransitionUtil.validate()
workflowTransitionUtil.progress()
log.debug(“Activity Approved”)
def date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd”);
String currentDate = dateFormat.format(date);
Date convertedToDate = dateFormat.parse(currentDate);
log.debug(“before date set”);
java.sql.Date sql = new java.sql.Date(convertedToDate.getTime());
cf = cManager.getCustomFieldObject(13500)
issue.setCustomFieldValue(cf, sql);
log.debug(“date is setting here inside draft to submit”)
}
}

}
}

Hi,

These documentation of Atlassian Developers seem like to be helpful.

1 Like