Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Having problem with script runner simple workflow validator. Tips?

Bryan Karsh
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.
April 3, 2014
Hi guys,

I've read several posts, but I still can't get this to work. Here is what I am trying to do:

Prevent transition to resolution unless there is a link to an issue from our Change Management queue,
with a key containing "RFC" -- example : RFC-1234

Ive tried this:

issueLinkManager.getLinkCollectionOverrideSecurity(issue).getOutwardIssues().any {Issue linkedIssue ->
    linkedIssue.key.contains('RFC') 
}

I've also tried this:

!issueLinkManager.getOutwardLinks(issue.getId())*.destinationObject.projectObject.name.contains('Change Management')

 

-- Neither work. Am I missing something? It doesn't matter if the I set the issue link in the transition screen,
 or if the link is set prior. Every time it fails.

Tips much appreciated.

1 answer

1 accepted

2 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Champion
April 4, 2014

Hi Bryan,

here the code that you need for your workflow validator:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.link.IssueLink;

Issue issue = issue;
Collection<IssueLink> links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId());
for(IssueLink il : links){
  if(il.getDestinationObject().getProjectObject().getKey().equals("RFC")){
     return true;
   }
}
return false;

Hope this helps.

Bryan Karsh
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.
April 4, 2014

Hmmm. Doesn't work still. the logs show this:

2014-04-04 14:35:12,226 http-bio-8080-exec-41580 ERROR bryank 875x2998119x1 1cjzjgv 66.54.212.165,10.110.199.61 /secure/CommentAssignIssue.jspa [atlassian.jira.workflow.OSWorkflowManager] Caught exception while attempting to perform action 5 from workflow 6184374 on issue 'SSESETEST-6'
[InvalidInputException: [Error map: [{}]] [Error list: [[Link to RFC is required!]]]


The issue has a link though.


I checked via console whether the collection was being populated, and it appears that it isn't:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.ComponentManager
import org.apache.log4j.Category


ComponentManager componentManager = ComponentManager.getInstance()



myissue = "SSESETEST-6"

issue = componentManager.getIssueManager().getIssueObject("$myissue")

Collection<IssueLink> links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId());

log.debug links.toString();

2014-04-04 15:04:32,680 http-bio-8080-exec-41578 DEBUG bryank 904x2999601x1 1cjzjgv 66.54.212.165,10.110.199.61 /secure/admin/groovy/GroovyRunner.jspa [onresolve.jira.groovy.GroovyRunner] Run called with args: null, {}
2014-04-04 15:04:32,836 http-bio-8080-exec-41578 DEBUG bryank 904x2999601x1 1cjzjgv 66.54.212.165,10.110.199.61 /secure/admin/groovy/GroovyRunner.jspa [onresolve.jira.groovy.GroovyRunner] []
2014-04-04 15:04:32,836 http-bio-8080-exec-41578 DEBUG bryank 904x2999601x1 1cjzjgv 66.54.212.165,10.110.199.61 /secure/admin/groovy/GroovyRunner.jspa [onresolve.jira.groovy.GroovyRunner] Time taken: 156

 

I get similar results regardless of the several tests I've tried.

Bryan Karsh
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.
April 7, 2014

Never mind -- I got it to work. Thanks!

Christian Schlaefcke
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 13, 2015

How ??? :-(

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events