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

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

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

"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

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
TAGS

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