I would like to implement post function script which run on Resolve Issue and Close Issue transitions and change issue status back to original if some conditions are fulfilled.
For example: post function script on "Resolve issue" transition step should change issue status to previous one if fix version does not equal some custom field version
Could you please advise how to make it if it's possible?
Thank you in advance.
> javax.script.ScriptException: javax.script.ScriptException: java.lang.IllegalStateException: You can not transition an issue with an invalid validation result.
It's telling you what is wrong... check the issue service javadocs, you need to look at the validation result (which has errors) before trying to do the transition.
Anyway, why don't you just use a validator to block the transition rather than confusing the user by having it transition to something unexpected?
If you really need to do this try using the fast track transition script with appropriate condition code. It's imperfect but it's likely to work better than if you write the same thing from scratch.
I don't use validator in this case because I was asked to make following functionality: user press Resolve button, and add some custom field values, then based on the input data the issue status should be changed to Resolved or remains in the current status, i.e. Open or Reopened. As far as I understood I have to make such functionality in post-function script. Do you think I am on the right way?
Could you please also tell where I can learn more about "fast track transition script "?
You can browse to the code from within the app - add the post-function, then click the view source link. https://studio.plugins.atlassian.com/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Fasttracktransitionanissue
> Do you think I am on the right way?
Without having full access to the requirement hard to say, but to me it sounds like, if the user clicks Resolve, then they end up in Open or Reopened, that might lead to confusion.
Thank you Jamie for the link!
I tried simple condition (e.g. currentUser == issue.reporter, and others) and action as "Close Issue" just to test Fast track transition, but it does not work.
Might it be so that I missed something?
I use JIRA v5.0.6#733 and groovyrunner 2.0.6,
I managed to change issue status to Reopned and used condition in Fast-track built in script (called as the last post function) on Resolve Issue post function
issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("custom_field")) != issue.getFixVersions()
but the issue is shown as Resolved until the issue is refreshed.
Jamie, could you please advise to solve it? I think re-indexing might help but re-index issue is not available as the post function.
I tried to implement it as the following
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.ComponentManager import com.atlassian.jira.bc.issue.DefaultIssueService import com.atlassian.jira.user.util.UserManager import com.atlassian.crowd.embedded.api.User import com.atlassian.jira.user.util.UserUtil import com.atlassian.jira.bc.ServiceResultImpl import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult import com.atlassian.jira.issue.IssueInputParametersImpl MutableIssue issue = issue user = issue.getAssignee() TransitionValidationResult validationResult = issueService.validateTransition(user, issue.getId(), 2, issueInputParameters) // 2 is the Close Issue transition ID issueService.transition(user, validationResult)
but ened up with error as
2012-09-04 16:41:31,395 http-80-3 ERROR admin 1001x772x1 1i7xhfp 10.161.201.17 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: issueService for class: Script35
2012-09-04 16:41:31,395 http-80-3 ERROR admin 1001x772x1 1i7xhfp 10.161.201.17 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: issueService for class: Script35
which I think should be resolved by defining issueService.
and I could not find how to define issueInputParameters.
Could you please help with it?
Thank you for your help. Yes, you are right. Initialization of issueService and issueInputParameters was missing. Now i added it as
def issueService = ComponentManager.getInstance().getIssueService() issueInputParameters = issueService.newIssueInputParameters()
and have got following error
javax.script.ScriptException: javax.script.ScriptException: java.lang.IllegalStateException: You can not transition an issue with an invalid validation result.
Do you know what might be wrong here, please?
We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...
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!
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