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

Force Transition the status trigger from different project

nostalgiaxx
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 20, 2020

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

Comment

Log in or Sign up to comment
Nic Brough -Adaptavist-
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.
September 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.

nostalgiaxx
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 20, 2020

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-
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.
September 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.

TAGS
AUG Leaders

Atlassian Community Events