Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
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

get the value of the "epic link" field Edited

Hello everybody.

I have created a script to find the value of the epic link field and add it to a new field. The script does not give me an error but it appends the object value of the "epic link" field in the new field

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def checkLink = {link -> false}
def cFieldLinkEpica = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Link'}

def cFieldEpicaAux = customFieldManager.getCustomFieldObject('customfield_13501')
issue.setCustomFieldValue(cFieldEpicaAux, cFieldLinkEpica)

The script I need is the following:

1. Let him check the type of problem.
2. Let him get the value of the "Epic Link" field for that problem.
3. If it is a subtask, find the value in the parent task of that subtask.
3. Add the value of the "epic link" field to the newly created field.

Thanks in advance

David

1 answer

0 votes

It's the line

def cFieldValueLinkEpica = issue.getCustomFieldValue(cFieldLinkEpica).toString()

throwing

com.atlassian.jira.issue.fields.ImmutableCustomField cannot be cast to java.lang.String

Epic Link fields do not contain strings.  You'll need to read the API Docs to find out how to get what you want out of it.  

Hello,

I have made this new script in which it no longer gives me the error, but it does not load the internal value of the epic link field in the new field ...

Please can someone help me ... thank you.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def checkLink = {link -> false}
def cFieldLinkEpica = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Link'}

def cFieldEpicaAux = customFieldManager.getCustomFieldObject('customfield_13501')
issue.setCustomFieldValue(cFieldEpicaAux, cFieldLinkEpica)

This is because your "Aux Epic field" is not an Epic Link type field and you are now trying to put an Epic Link into it.  I suspect the content is actually an issue from https://library.adaptavist.com/entity/update-the-epic-link-for-an-issue-in-jira, so you'll probably need to extract something from the Epic you're trying to link to - summary, key, epic name etc.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

829 views 26 33
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