It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Exclude or clear custom field for a cloned issue Edited

Team,

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. 

Thanks,
Suresh

2 answers

1 accepted

0 votes
Answer accepted

Hi Suresh,

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.

Regards,

Kristian

Hi Suresh,

I can confirm that I have updated my example above to show how to remove the value from a single line select list type custom field as well. 

Regards,

Kristian

Thank you for your response Kristian!

I see below static error when configured and ended in failure. IssueLink not declared.  Is there something I need to add further?

2019-09-16 23_48_18-Script Listeners - JIRA.png

Attached screenshot.

Hi Suresh,

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.

Regards,

Kristian

Hi Kristian,

It worked like a charm!

Yes, you're correct. I configured for Issue Created which caused static type checking warning ending up in failure. Changing the Event to IssueLink Created resolved issue.

Thank you so much!

Thanks,
Suresh

Hi Kristian,

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.

Please advise.

Thanks,
Suresh

Hi Suresh,

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.

Regards,

Kristian

By the way Field is Single line text, custom field.
Environment is Jira cloud

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

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 ...

334 views 1 3
Join discussion

Community Events

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

Events near you