Issue Transitioning oddity

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() + ")");

2 answers

This widget could not be displayed.

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.

This widget could not be displayed.

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

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 ..."

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...

510 views 3 18
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