Having problem with script runner simple workflow validator. Tips?

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

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.

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.

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

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

173 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you