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,553,173
Community Members
 
Community Events
184
Community Groups

Force Transition the status trigger from different project

Hi All,

I'm new to jira scriptrunner 6.7.0.

I've two project (Project A & Project B). Based on post-function on Project B, i want it to force change the issue status Project A.

Need your help.. It's possible?

1 comment

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.
Sep 20, 2020

"force a change", no.  You can't force any change that is not valid in the target.  (Well, actually, you can force it, but that breaks things so badly, you're never going to be able ot recover).

Asking an issue in a different project to take a valid move through its workflow when you do something with the current issue - absolutely fine.

You will need to write some code for the post-function in project B works out what issue to change in A, checks what transitions are valid for it for its current status and asks it to go through the appropriate ones to move it into the desired status.

Below code it will transition FLD-400 to "Cancelled". but when i ran, it return error as below. Can someone help?

 

I got error as below, seem like coming from line "transientVars["Cancelled"] as int"

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead
 at Script463.run(Script463.groovy:74)

 

Code as below:

def issueA = issueManager.getIssueObject("FLD-400");

//Test issue service. Transition the issue at FLD
def issueService = ComponentAccessor.getComponent(IssueService);
issueService.getIssue(user, "FLD-400");
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setComment("This is a comment");
issueInputParameters.setSkipScreenCheck(true);

def transitionOptions= new TransitionOptions.Builder()
.skipConditions()
.skipPermissions()
.skipValidators()
.build()

//Get the action id (trasition id)
def actionID = transientVars["Cancelled"] as int;
def transitionValidationResult = issueService.validateTransition(user, issueA.id, actionID, issueInputParameters, transitionOptions)

if (transitionValidationResult.isValid()) {
issueService.transition(user, transitionValidationResult).getIssue()
}

log.error "Transition of issue ${issueA.key} failed. " + transitionValidationResult.errorCollection

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.
Sep 21, 2020

You can't just cast an object to an integer and hope the computer can guess what you want it to do.  You'll need to unpack transientVars in full and extract the action id from it.

Comment

Log in or Sign up to comment