We have used script runner functions in issue filters successfully but have not been able to use them in workflow validators.
The objective is to prevent the closure of an issue if it has linked issues that are still open. For example issueFunction in linkedIssuesOf("status = open"). The validator returns a workflow exception indicating No such property: issueFunction. I suspect this may be due to missing import statements or just bad syntax but have not been able to find any examples of using the script runner issueFunction in a validator.
Hi Robert,
Try using the script below in a Custom script validator
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.opensymphony.workflow.InvalidInputException import com.opensymphony.workflow.WorkflowContext Issue issue = issue def issueLinkManager = ComponentAccessor.getIssueLinkManager() String currentUserName = ((WorkflowContext) transientVars.get("context")).getCaller() def currentUser = ComponentAccessor.getUserManager().getUserByKey(currentUserName) def flag = issueLinkManager.getLinkCollection(issue, currentUser)?.allIssues?.find {it.status.statusCategory.name != "Complete"} if (flag) throw new InvalidInputException("At least one linked issue is still open or in progress")
You may need to replace 'Complete' with the status category name that you have configured for closed issues.
Tested with a JIRA7 instance. Please let me know if this does the trick
regards, Thanos
I cut pasted the script exactly as shown and received the following error message.
An unknown exception occured executing Validator com.atlassian.jira.workflow.SkippableValidator@28db70f8: root cause: Cannot cast object 'com.innovalog.jmwe.IssueProxy@45c36f70' with class 'com.innovalog.jmwe.IssueProxy' to class 'com.atlassian.jira.issue.Issue'
It seems that you have tried to perform an illegal workflow operation.
If you think this message is wrong, please contact your JIRA administrators.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert
Sorry for the misunderstanding, I though you were using ScriptRunner (even though I believe that the issueFunction in linkedIssuesOf("status = open") is a ScriptRunner scripted JQL function)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must have ScriptRunner Robert so you should just be able to replace the validator with the one provided by Thanos, rather than using whatever function JMWE is providing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have the JIRA add-on titled "Adaptavist ScriptRunner for JIRA" installed and have successfully used the ScriptRunner function "issueFunction in linkedIssuesOf" in issue filters. We have the evaluation version of the ScriptRunner installed as shown in the add-on maintenance information below, so perhaps that is the problem. We were hoping to verify functionality prior to recommending the purchase of a 2000 user license.
Is a different version of ScriptRunner or another component or tool that is required?
Version: 4.3.13
Vendor: Adaptavist.com Ltd
Add-on key: com.onresolve.jira.groovy.groovyrunner
License details: Evaluation, Unlimited-user commercial license, Standard, expires 12/Jan/17
License status: Valid
License SEN: SEN-L8985939
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check https://answers.atlassian.com/questions/134531 of how to use JQL in groovy script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.