Issue Clone Does Not Create Cloned Issue

I'm testing the built-in script workflow function in Script Runner that Clones an issue and links.

I set up basic parameters (e.g. Target Project, Target Issue Type, Issue Link Type/Direction).

The script is configured in a Post Function for one of the transitions in Project A's workflow. It supposed to create a clone of this issue in Project B. Whenever I run that transition, the cloned issue is not generated in Project B.

I'm trying to figure out how to troubleshoot this and how to determine why it's not working. Does the user who is performing the transition in Project A have to have permissions to create issues in Project B?

I also set up a script through Add-Ons > Script Listeners > Clones an issue and links, , which gives me the option to select a project key and an event that will trigger the script (along with the other parameters of the clone). But the issue doesn't get cloned here either.

What am I missing?

3 answers

Hey Julio,

do you also use that event in your workflow? Or are you trying to clone JSD issues ? This doesn't work really well ... but Create on Transition does ok.
If this doesn't help a little more context would be great or some details of the workflows

Greets
Simon 
Bildschirmfoto 2015-03-27 um 08.16.45.png
Bildschirmfoto 2015-03-27 um 08.19.18.png 

@Julio Ochoa you can attach an event in your workflow by editing the standard post function 5. (Fire a Generic Event event that can be processed by the listeners.) Edit this one and change it to your own event . :) Added a screenshot above.

Simon, I performed additional testing yesterday and determined that the reason why the cloned issue was not being created was because the user initiating the transition in the source issue project didn't have create issue permissions in the target project. So far I worked around this by changing the create issue permissions in the target calendar. This is not ideal though. Will the suggestion that you mentioned here preclude the need to change permissions in the target project?

Simon,

The answer to both questions is No. The issue I'm cloning is in a regular issue from a regular project (not from JSD). Also I didn't find a way to link the event to the workflow, so I created a post function right in the workflow.

I'll attempt to describe the process that I followed.

I have a workflow has 12 statuses. In the transition from one of those statuses, I created a Post Function > Script Post-Function > Clones and Issue and Links.

I then defined the criteria for the script.

There are no other post functions on this transition other than the default ones. There's also a project role based condition and a required field validator.

Below is the excerpt of the XML that the workflow generated after I added the built-in script at that step. My only doubt at this point is whether the user executing the transition has to have issue create permissions in the target project. Let me know if you need additional info.

 

<step id="10" name="Final for Depts. Release">
      <meta name="jira.status.id">10522</meta>
      <actions>
        <action id="201" name="Release to Depts" view="fieldscreen">
          <meta name="jira.description"></meta>
          <meta name="jira.fieldscreen.id">10631</meta>
          <restrict-to>
            <conditions>
              <condition type="class">
                <arg name="jira.projectrole.id">10304</arg>
                <arg name="class.name">com.atlassian.jira.workflow.condition.InProjectRoleCondition</arg>
              </condition>
            </conditions>
          </restrict-to>
          <validators>
            <validator name="" type="class">
              <arg name="contextHandling"></arg>
              <arg name="hidFieldsList">customfield_10554@@</arg>
              <arg name="class.name">com.googlecode.jsu.workflow.validator.FieldsRequiredValidator</arg>
            </validator>
          </validators>
          <results>
            <unconditional-result old-status="Not Done" status="Done" step="12">
              <post-functions>
                <function type="class">
                  <arg name="FIELD_TARGET_ISSUE_TYPE">10401</arg>
                  <arg name="full.module.key">com.onresolve.jira.groovy.groovyrunnerrungroovy-function</arg>
                  <arg name="canned-script">com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue</arg>
                  <arg name="FIELD_CONDITION"></arg>
                  <arg name="class.name">com.onresolve.jira.groovy.GroovyFunctionPlugin</arg>
                  <arg name="FIELD_TARGET_PROJECT">MT</arg>
                  <arg name="FIELD_LINK_TYPE">10001</arg>
                  <arg name="FIELD_ADDITIONAL_SCRIPT"></arg>
                </function>
                <function type="class">
                  <arg name="full.module.key">com.atlassian.jira.plugin.system.workflowupdateissuestatus-function</arg>
                  <arg name="class.name">com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction</arg>
                </function>
                <function type="class">
                  <arg name="full.module.key">com.atlassian.jira.plugin.system.workflowcreatecomment-function</arg>
                  <arg name="class.name">com.atlassian.jira.workflow.function.misc.CreateCommentFunction</arg>
                </function>
                <function type="class">
                  <arg name="full.module.key">com.atlassian.jira.plugin.system.workflowgeneratechangehistory-function</arg>
                  <arg name="class.name">com.atlassian.jira.workflow.function.issue.GenerateChangeHistoryFunction</arg>
                </function>
                <function type="class">
                  <arg name="full.module.key">com.atlassian.jira.plugin.system.workflowreindexissue-function</arg>
                  <arg name="class.name">com.atlassian.jira.workflow.function.issue.IssueReindexFunction</arg>
                </function>
                <function type="class">
                  <arg name="eventTypeId">13</arg>
                  <arg name="full.module.key">com.atlassian.jira.plugin.system.workflowfireevent-function</arg>
                  <arg name="class.name">com.atlassian.jira.workflow.function.event.FireIssueEventFunction</arg>
                </function>
              </post-functions>
            </unconditional-result>
          </results>
        </action>
      </actions>
    </step>

I'm looking at the documentation some more, and I'm wondering if I misunderstood how the add-on works.

There are examples of scripts in the documentation. For instance, this page documents the script for cloning an issue (with dependency) https://jamieechlin.atlassian.net/wiki/display/GRV/Post+Functions+With+Comments#PostFunctionsWithComments-Cloneissuewithdependencylink

Am I supposed to have the script's code saved somewhere on the JIRA server? I was under the impression that, at least for the built-in scripts, the Add-on would keep those scripts somewhere and I was just providing it the criteria.

Thanks for any help on this...

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

128 views 0 3
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