Update the resolution field in issue on workflow transition

Hi all,

There are two customized workflows defined at the moment. There is a postFunction defined for each of the workflows separately. But, there is a scenario when the transition can happen from one state of workflow1 to another state of workflow2. We cannot set a postfunction for such a transition, but it should happen such that on this particular transition the resolution has to be set to "None". I have to do this in the code itself. Right now am trying with some groovy scripts but it seem not to work, can anyone help me on this scenario.

I had the following groovy which is not serving the purpose. Could anyone please help me?

import com.atlassian.jira.issue.IssueManager;
			import com.atlassian.jira.issue.MutableIssue;
			import com.atlassian.jira.project.Project;
			import com.atlassian.jira.project.ProjectManager;
			import com.atlassian.jira.issue.issuetype.IssueType;
			import com.atlassian.jira.workflow.JiraWorkflow;
			import com.atlassian.jira.component.ComponentAccessor;
			import com.opensymphony.workflow.loader.ActionDescriptor;
			import com.opensymphony.workflow.loader.FunctionDescriptor;
			import webwork.dispatcher.ActionResult;
			import com.atlassian.core.util.map.EasyMap;
			import com.atlassian.core.ofbiz.CoreFactory;
			import com.atlassian.jira.ComponentManager;
			IssueManager issueManager = ComponentAccessor.getIssueManager();
            MutableIssue targetIssue = issueManager.getIssueObject("ALM-1696");
		          ProjectManager projectManager =ComponentAccessor.getProjectManager();
              String tartgetProject=targetIssue.getProjectObject().getKey();
          Project targetProject = projectManager.getProjectObjByKey(tartgetProject);
		            IssueType issueTypeObject=null;
					def issueType = "Bug"
					def Status = "Code/Hardware Bug (Response/Resolution)"
             Collection<IssueType> issueTypes=   ComponentAccessor.getIssueTypeSchemeManager().getIssueTypesForProject(targetProject);
             Iterator itr=issueTypes.iterator();
			//	ComponentManager componentManager = ComponentManager.getInstance()
             //  User remoteUser = componentManager.getJiraAuthenticationContext().getUser() 
                 IssueType projectIssueType=(IssueType)itr.next();
		   JiraWorkflow workflow=ComponentAccessor.getWorkflowManager().getWorkflow(targetProject.getId(), issueTypeObject.getId());
		   Collection<ActionDescriptor> actions = workflow.getAllActions();
		   authenticationContext =ComponentAccessor.getJiraAuthenticationContext()	
		    for (final ActionDescriptor actionDescriptor : actions)
            if (actionDescriptor.getName().contains(Status))
            // targetIssue.store();
			// targetIssue.update(ComponentAccessor.getUserManager().getUserObject("some email id"),targetIssue, null,false) 
               Map actionParams = EasyMap.build("issue", targetIssue.getGenericValue(), "issueObject", targetIssue, "remoteUser", ComponentAccessor.getUserManager().getUserObject("some email id"), "dispatchEvent", Boolean.FALSE);
               ActionResult aResult = CoreFactory.getActionDispatcher().execute(ActionNames.ISSUE_UPDATE, actionParams); 




1 answer

1 accepted

1 vote

Use IssueTransition validateTransition and transition methods. You can set the resolution in IssueInputParameters.

Could you please provide me with a snippet?

If you search for samples in this forum or in google, you will find quite a few ;)

I don't know why I typed that comment :P Was too lazy I guess to search. Got it thanks. :)

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,316 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot