Problems in cloning issue and changing issueType

Hi,
I’m trying to clone issue and then changing issueType in the issue clone and I’ve 2 kinds of problems.

The 1st:
my issue is cloned by a custom class extending CloneIssueDetails.
In my doExecute() implementation, soon after having called the super.doExecute(), I’m not able to get the cloned issue but I need it to do some operations on the clone.
I made a workaround for this problem, using a customField that can help me to understand if it’s my issue clone, triggered on the ISSUE_CREATED event and then reading this cf.
Is there any other way to know which is the issue clone just after cloning an issue ?

The 2nd big (worst) problem is that I need to change issueType on the issue clone.
To do this, when I’m called by the ISSUE_CREATED event, I change the type to the issue and then I call the

workflowManager.migrateIssueToWorkflow(issue, newWorkflow, status);

but I got the following error:

Can’t transition workflow instance #175310. Current state is 3, requested state is 1

even if the issue is anyway created. I’ve seen that when I’m called by ISSUE_CREATED event, the workflow of the new issue clone is not yet activated (maybe the new issue is not yet completely ready?)
So has anyone any suggestion on how to change issueType on a newly created issue clone ?
Thank you.

Hi @francesco.rotondella,

AFAIK, it would look like on ISSUE_CREATED event that the workflows are not yet ready to be activated thus the error. Although, as per conversation, this did not work for you? What were your issues?

Cheers,
Anne Calantog

Yes exactly.
I already read that thread and also if it’s signed as “solved” it’s not really solved.
The solution suggested there by Ilia Ostroumov (just after the accepted solution) is not working for me.
Imho I suppose it’s better to send the ISSUE_CREATED event a bit later instead of issueing another event when workflow is activated.
Obviously I have this same issue if I write a post function, instead triggering directly on ISSUE_CREATED_EVENT