Changing IssueType within Workflow Validator Class causes Workflow Post Functions to stop working

Hans Pesata July 6, 2017

Hi!

JIRA 7.3.6 Standalone
Atlassian Plugin SDK 6.2.2

We have created an Atlassian Plugin which changes the IssueType of another linked Issue within a Workflow Validator Class:

import com.opensymphony.workflow.Validator;  

// validate
public void validate(Map transientVars, Map args, PropertySet ps) throws InvalidInputException {  
final Issue issue = (Issue)transientVars.get("issue");    
…  
IssueManager im = ComponentAccessor.getIssueManager();  
MutableIssue linkedIssue = im.getIssueObject(issue.getId());   linkedIssue.setIssueType(bug);   im.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), linkedIssue, EventDispatchOption.DO_NOT_DISPATCH, false); 
...
}  

Changing the IssueType of the linked Issue works fine and it causes the linked Issue to have another Workflow, which is correct.
 
Though everything seemed to work fine, we realized, that after changing the IssueType, no more Workflow Post-Functions are called anymore when State Transitions occur for the linked Issue.

Any Ideas on how to get the Workflow Post Functions working in this scenario would be greatly appreciated!

Thanx in advance,
Hans

2 answers

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2017

NO!  Never do this, it's an utter disaster no matter what you do.

A validator should make NO changes to any data.  It should return either "True" or "False" and do nothing else.

Hans Pesata July 7, 2017

Hi Nic!

Thanx for replying.

As far as I can see, the "validate" method doesnt't have a return value, You either throw an InvalidInputException or not.

Besides the validator being the wrong place for my implementation (which I can easily move to a post function), this fact doesnt seem the source of my Problem.

I suppose changing the IssueType isn't sufficient enough to do all the neccessary background-steps which probably have to be done to have the workflow working correctly (including the post functions).

Unfortunately Jira display everything fine, the Issue with the new IssueType and the switched Workflow, and doesn't tell me, that something is missing or wrong.

When I use the Move Issue Form to change just the IssueType, everything works fine. So I suggest I will have to look at the Sources of this Action and extract what is need.

regards,

Hans
Hans

0 votes
Hans Pesata July 25, 2017

Hi!

If anybody needs something like this:

The function migrateIssueToWorkflow within WorkFlowManager used witin a transition post function worked for me.

regards,
Hans

Suggest an answer

Log in or Sign up to answer