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

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
4,551,664
Community Members
 
Community Events
184
Community Groups

transition linked issue

I need to make a transition on a linked issue after pass the conditions.


import org.apache.log4j.Category
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.util.JiraUtils
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.MutableIssue
//


def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)


IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager()
WorkflowTransitionUtil tx = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)

for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
def linkedIssue = link.getDestinationObject();
if (link.issueLinkType.name != "is blocked by") {
if (link.getSourceObject().getProjectObject().getKey().contains("OR")){
if (link.getSourceObject().getStatus().getName().contains("Blocked")){
try{
tx.setIssue((MutableIssue) linkedIssue);
tx.setAction(921)
tx.validate()
tx.progress()

}
catch (Exception e) {
UserMessageUtil.error('ERROR: ')
}
}
}
}
}

 Always the code pass to the catch. I don't know what is the problem. the action id is the correct. the execution log is empty.


Also I want to put in the code which user who performs the action. I don't know how to do it.


thanks in advance.

1 answer

0 votes
Marcos Sanchez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 22, 2018

Hi,

Some things that got into my head when I saw your code:

1- Check that you (or the user who will trigger this) are able to transition from Blocked making the transition which has the 921 id. 

2- Normally the UserMessageUtil.error('ERROR: ') gives me issues getting traces... You could try replacing it for return e.printStackTrace() to see some traces of the exception.

3- Maybe the problem is that your script doesn't passes the tx.validate() step, you should have more information about this if point 2 works for you.

 

To get which user performs the action, use this:

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

 

Regards,
Marcos

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events