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

Attempting to set Epic Link yields "unable to cast string to issue" Edited

I'm attempting to create issues that are associated with a specific Epic. I've created a custom field, created an action associated with that custom field, and am able to successfully create issues within the action. What I'm not able to do is SET Epic Link for the issues that I'm creating.

Code looks like this (I've left commented alternative methods that also don't work in there):

string[] custom_fields_mapping;
custom_fields_mapping = addElement(custom_fields_mapping, "assignee");
custom_fields_mapping = addElement(custom_fields_mapping, currentUser());
// custom_fields_mapping = addElement(custom_fields_mapping, "Epic Link");
// custom_fields_mapping = addElement(custom_fields_mapping, key);

string k = createIssue(
"T1", // project
"", // parent task key (blank for non sub-tasks)
"Task", // issueType
"Epic Security Review" , // summary
"Medium", // priority name
"", // description
{}, // array of components
"", // due date
"1h 30m", // estimate duration
"", // security level
// {} // array of custom or system field values
custom_fields_mapping // array of custom or system field values

logPrint("ERROR", "key = " + key);
logPrint("ERROR", "key is null!");

%k%.#{Epic Link} = key;

Passing the key in the custom_fields_mapping causes the createIssue to fail. If instead I createIssue without the custom_feild_mapping, and then attempt to update the recently created issue with something like %k%.#{Epic Link} fails the update with an error. Here's some log output from a recent attempt... as you can see the key value is a valid key (non-null):

2017-11-02 13:59:37,672 pool-26-thread-8 ERROR admin 839x801x1 a9k9vr /rest/keplerrominfo/blitzactions/latest/input/executeAction [c.k.s.lang.routines.LogPrintRoutine] key = TT-3

2017-11-02 13:59:37,679 pool-26-thread-8 ERROR admin 839x801x1 a9k9vr /rest/keplerrominfo/blitzactions/latest/input/executeAction [c.k.j.c.hostapp.impl.KIssueServiceImpl] Update failed for issue >>T1-42<<, error was java.lang.ClassCastException: java.lang.String cannot be cast to com.atlassian.jira.issue.Issue


Work is being done using Jira 7.5.1, Power Actions 4.1.1

This feels similar to this existing question, which was not satisfactorily answered.

1 answer

Hi there, Christian.

"Epic Link" isn't a field that Power Scripts / Power Actions understands how to handle natively (at least by referencing the field name).

One way I've gotten around this is to find the custom field ID of "Epic Link" and then make that map in the sil.aliases file.

For example (in sil.aliases)

epicLink = customfield_12345

Then instead of referencing the field as "Epic Link" in your script, you'd reference it as epicLink.

Hope this helps!

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 03, 2019 in Marketplace Apps

How to estimate projects more accurately?

Gaining insight into your team’s effectiveness and choosing the right estimation technique.   Estimating projects is hard. It is because people have the tendency to underestimate the time thin...

272 views 2 8
Read article

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