I am trying to transition issues through the workflow using the code below as a workflow POST function. When the script executes it appears to run fine with no errors. The workflow buttons on the top are updated with the correct destination transitions but, the status of the workflow shows the original destination and not the correct one it transitioned to.
Any Assistance would be appreciated.
Thanks!
log = Category.getInstance("com.verizon.jira.groovy") MutableIssue issue = issue Status initialStatus = issue.statusObject log.warn("Starting ARS_CheckForDomestic.groovy (ID: " + issue.key.toString() + ")"); def indexManager = ComponentAccessor.getIssueIndexManager() CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField cfLocation = customFieldManager.getCustomFieldObjectByName( "Location" ); String cfvLocation = issue.getCustomFieldValue(cfLocation); if (cfvLocation == "Domestic (USA, CA)") { User user = ComponentManager.getInstance().getUserUtil().getUser('system'); IssueService issueService = ComponentManager.getComponentInstanceOfType(IssueService.class) IssueInputParameters issueInputParameters = new IssueInputParametersImpl([:]) //issueInputParameters.setAssigneeId("system"); issueInputParameters.setStatusId("Pending Approval") IssueService.TransitionValidationResult validationResult = issueService.validateTransition(user, issue.id, 91 as Integer, issueInputParameters) def errorCollection = validationResult.errorCollection log.debug(errorCollection) if (! errorCollection.hasAnyErrors()) { issueService.transition(user, validationResult) } else { log.warn("Error transitioning issue.") } } log.warn("Completed ARS_CheckForDomestic.groovy (ID: " + issue.key.toString() + ")");
This is not at all straightforward. The database commit is not done until the first transition finishes, and you end up with a mishmash of two different states with your approach.
You should try the built-in fast-track script. Everything above your "if" can go in the Condition, the issueInputParameters stuff you pass in the "additional code" section.
I started out with a listener with the following:
Project: Target Project
Events: Issue Updated
Condition: issue.status == 'Pending Missing VZID Approval' && cfValues['Location'] == 'Domestic (USA, CA)'
Action: Target Transition.
This resulted in no transition. I went so far as to remove the Condition and still was not getting transitioned.
Thoughts?
Thanks,
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your condition is not right, but what is this for, fast-track? Have you decided to use the built-in script? The first part should be: issue.statusObject.name == ... If Location is a select list you should use: cfValues['Location']?.value == "Domestic ..."
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.