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

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

435 views 3 17
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