We are using the Jira cloud environment, we have couple of custom field which we don't want to be copied when cloned using Jira in-built functionality. The only possibility I see here is using Jira script runner plugin by configuring the listner. Could anyone help me with the script?
Environment: Jira cloud
Custom field, Single line text field
Seems cloud script runner works in a different way than the Jira server.
Thank you for your question.
I can confirm that to have a field value removed when an issue is cloned using the built-in Jira clone issue functionality with ScriptRunner for Jira Cloud that you will need to create a Script Listener and configured to fire on the Issue Link Created event.
The script for the listener will need to check the type of the issue link that is created and if it has the link type of cloners then will need to update the cloned issue to make a put request to the Issue rest API in order to update the fields that you want to set to have a null value.
I have created an example script located here which you can configure as a script listener on the Issue Link Created event in order to clear the value of the Description field and a specified Single line text field on the cloned issue.
You will then be able to use this script as a reference guide and to modify this example in order to set other fields that you want to remove the values from when the issue is cloned.
If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.
Can I please ask you to confirm if you set your Script Listener to be configured on the IssueLink Created event as the listener will need to be configured on this event in order for the issueLink variable to be available to the script.
I can confirm that if you use the Issue Created event which is similar that you will get this static type checking warning and that you should change the event to be the IssueLink Created event to resolve this warning.
Listener works fine as intended. However, we observer that page loads earlier than the script executes. Then refresh of the page would clear these fields. Is there way to avoid loading of the page before script executes or alternate way to implement this using issuecreated event to avoid this lag.
Thank you for your response.
I can confirm that unfortunately, the reason the issue loads before the listener is run is due to the fact that Atlassian has designed Jira Cloud to execute in a completely asynchronous manner as described inside of our documentation pages located here and here.
This, unfortunately, means that there is no way that we can avoid the issue screen loading before the script listener has run to avoid users having to refresh the screen to see the values cleared.
As explained this caused by the way that Jira Cloud is architected and as this how Atlassian make it run then there is no way to work around this limitation.
Learn how to use two new reports for next-gen projects in Jira Cloud: Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events