Hi
I am trying to use Scriptrunner to perform an action when an issue is created if it is cloned and a different action if it is not cloned. What I want to do is:
When created:
IF not cloned
- edit the summary and
- add a comment to reporter 'Hi, these are the next steps . . .'
ELSE (cloned)
- transition to cancelled/closed and
- add a comment to reporter 'create a new ticket from create button'
The below code works in the console when I run it on a cloned or non-cloned issue.

But I can't get it to work for real.
I tried it in a workflow post-function on the Create transition (the only difference is the def issue line is not included) and the IF always ran even if the issue was cloned.
I tried it as a Listener on the Issue Created event (the only difference was the def issue line became def issue = event.issue) but the result was the same.
It seems the code is running before the clone link has been added ??
Any advice what I can do instead? I considered a listener on 'IssueLinkCreatedEvent' but the problem there would be that I'd need a separate listener to run on create for the non-cloned actions but it would run on all issues including cloned and then I'd have two contradictory comments to the reporter.
Thanks in advance, and any general advice about improving the code is welcome too
Julia