Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Script Runner- Clone issue Post Function, issue with clearing the Epic Link field

Hi,

I am using Script Runner's Clone Issue post-function to clone an issue into a different project and issue-type. During the cloning I want to clear some fields in the cloned issue.

in the Additional issue actions field, I can successfully use the following code;

     def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Story Points'}
     issue.setCustomFieldValue(cf, null)
     issue.summary = "CLONE - " + transientVars["issue"].summary;

and the Story Points field is cleared.

However when I use the same code to clear the Epic Link field as below, the Epic Link field remains the same

     def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Links'}
     issue.setCustomFieldValue(cf, null)
     issue.summary = "CLONE - " + transientVars["issue"].summary;

Does anyone have any ideas as to why this is the case and how to resolve it?

3 answers

1 accepted

1 vote
Answer accepted

Epic Links is not a real custom field that you can clear like that. See the documentation here: https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Clonesanissueandlinks - to see how to control which links are copied.

I had to use the following to get the epic link cleared:

 

checkLink = {link -> link.issueLinkType.name != "Epic-Story Link"}

 

Note that this throws me an in-line 'no such property' error, but it does seem to work.

Just cross-posting my answer from a similar question that referenced this one.

The Epic Link is actually its own separate custom field, distinct from regular links. As such, you'll need to clear it separately from the checkLinks closure. You can do both (set checkLink and clear the Epic Link), or just do the one that suits you in the Additional Actions section of a post function. To clear it, just set the value to null.

checkLink = {link -> false};
def epic = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Link'}
issue.setCustomFieldValue(epic, null)

Take note that your mileage may vary on accessing the Epic Link through the custom field manager, depending on what version of JIRA (and JIRA Software vs JIRA Agile) and ScriptRunner you're using. I tested the above on JIRA 7 with the latest ScriptRunner (4.3.5).

Hi Jamie, thanks for the answer. However, when I put the checkLink = {link -> false};  code into the Additional Code field, it cleared some test links I had in the issue, but it didn't clear the Epic link field.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

251 views 3 20
Read article

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