Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

I am getting the error in post workflow transistion

The following script is to transition of parent worklow based on subtask

whenever moving any associated subtask to in progress status automatically move the parent story to in progress

 

code is below

import com.atlassian.jira.component.ComponentAccessor;
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue;


String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
//WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
def workflowTransitionUtil = ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class)
//ef workflowTransitionUtil = ComponentAccessor.getWorkflowTransitionUtil().class
//WorkflowTransitionUtil workflowTransitionUtil = ComponentAccessor.getWorkflowTransitionUtil()
MutableIssue parent = issue.getParentObject().getKey() as MutableIssue
String originalParentStatus  = parent?.status?.name

if (issue.issueType.name == "Sub-Task" && originalParentStatus == 'To Do' ) {
   
   // workflowTransitionUtil.setIssue(getMutableIssue());

    workflowTransitionUtil.setIssue(parent)
    workflowTransitionUtil.setUserkey(currentUser)
    workflowTransitionUtil.setAction(41)
    workflowTransitionUtil.validate()
    workflowTransitionUtil.progress()
}


error I am getting
ava.lang.NoClassDefFoundError: groovy/lang/GroovyObject
	at Script3691.run(Script3691.groovy:14) [?:?]
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runScriptAndGetContext(AbstractScriptRunner.groovy:179) [?:?]
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner$runScriptAndGetContext$3.callCurrent(Unknown Source) [?:?]
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runScriptAndGetContext(AbstractScriptRunner.groovy:298) [?:?]
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner$runScriptAndGetContext$2.callCurrent(Unknown Source) [?:?]
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runScript(AbstractScriptRunner.groovy:310) [?:?]
	at com.onresolve.scriptrunner.runner.ScriptRunner$runScript$11.call(Unknown Source) [?:?]
	at com.onresolve.scriptrunner.canned.jira.utils.TypedCustomScriptDelegate.execute(TypedCustomScriptDelegate.groovy:19) [?:?]
	at com.onresolve.scriptrunner.canned.jira.utils.TypedCustomScriptDelegate$execute$0.call(Unknown Source) [?:?]
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction.execute(CustomScriptFunction.groovy:53) [?:?]
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction$execute.callCurrent(Unknown Source) [?:?]
	at com.onresolve.scriptrunner.canned.jira.workflow.AbstractWorkflowCannedScript.execute(AbstractWorkflowCannedScript.groovy:23) [?:?]
	at com.onresolve.scriptrunner.canned.jira.workflow.AbstractWorkflowCannedScript$execute$5.call(Unknown Source) [?:?]
	at com.onresolve.scriptrunner.jira.workflow.AbstractScriptWorkflowFunction$_run_closure2.doCall(AbstractScriptWorkflowFunction.groovy:91) [?:?]
	at com.onresolve.scriptrunner.jira.workflow.AbstractScriptWorkflowFunction$_run_closure2.doCall(AbstractScriptWorkflowFunction.groovy) [?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor12582.in

Log's referral number: c9fa4a16-289a-41d1-9da7-351f12a25765

jvoke(Unknown Source) [?:?]

2 answers

2 accepted

0 votes
Answer accepted
Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 13, 2023

Hi @Jagadeesh Chander I use a listener to achieve the same thing.
Here's the code.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.applinks.api.application.jira.JiraApplicationType
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.opensymphony.workflow.loader.ActionDescriptor
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def workflowManager = ComponentAccessor.workflowManager
def issueManager = ComponentAccessor.issueManager
def issueService = ComponentAccessor.issueService
def customFieldManager = ComponentAccessor.customFieldManager
def issue = event.issue
   
def parentissuekey = (String) issue.parentObject.getKey()  // parent key of sub-task
def parentissue = issueManager.getIssueByCurrentKey(parentissuekey) // parent issue of sub-task
       
    int Workflowactionid = 11 // your workflow action ID

    if (parentissuekey != null){
     
                if (parentissue.status.name == "To Do") { // Transition if current status is To Do
      if (issue.projectObject.key == "Your Project Key") { Workflowactionid = 11
       def issueInputParameters = issueService.newIssueInputParameters()
 
def transitionValidationResult = issueService.validateTransition(currentUser, parentissue.id, Workflowactionid, issueService.newIssueInputParameters())

    if (transitionValidationResult.valid) {
        def transitionResult = issueService.transition(currentUser, transitionValidationResult)
        if (transitionResult.valid) {
            log.debug "Transitioned issue ${parentissue} through action ${Workflowactionid}"
        } else  {
            log.warn 'Transition result is not valid'
        }
    } else {
       
        log.warn 'The transitionValidation is not valid'
    }
    } else { def issueInputParameters = issueService.newIssueInputParameters()
 
def transitionValidationResult = issueService.validateTransition(currentUser, parentissue.id, Workflowactionid, issueService.newIssueInputParameters())

    if (transitionValidationResult.valid) {
        def transitionResult = issueService.transition(currentUser, transitionValidationResult)
        if (transitionResult.valid) {
            log.debug "Transitioned issue ${parentissue} through action ${Workflowactionid}"
        } else  {
            log.warn 'Transition result is not valid'
        }
    } else {
       
        log.warn 'The transitionValidation is not valid'
    }
    }
    }
    }

Great Thanks Its working with Listener script

Like Craig Nodwell likes this
0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 13, 2023

That's not the right way to get the classes you need.

Have a look at https://library.adaptavist.com/entity/transition-original-issue-according-to-cloned-issue instead - it transitions another issue in a post-function, albeit with different criteria.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events