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() while(itr.hasNext()){ IssueType projectIssueType=(IssueType)itr.next(); if(issueType.equals(projectIssueType.getName())) {issueTypeObject=projectIssueType; break;} } 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.setResolution(null); // 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); } }
Thanks,
Hemanth
Use IssueTransition validateTransition and transition methods. You can set the resolution in IssueInputParameters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you search for samples in this forum or in google, you will find quite a few ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know why I typed that comment :P Was too lazy I guess to search. Got it thanks. :)
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.