Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

CSV Import Can't Find Link in Post Function or Listener

Scott Boisvert
Contributor
June 17, 2019

I have a script in ScriptRunner that I've tried as both a post function and as a listener (on the create issue event). When I create the issue manually (by clicking on the Create button) everything works fine (both as a post function and as a listener). However, when I perform a CSV import to create issues, the script errors/can't find the link to one another users story. This link is created during the import.

The funny part is that when I'm cycling through the links, it finds the Epic Link no problem, which is created at the same time. 

So what is different about the create process on an a CSV upload compared to a manual creation when it comes to link creation? Or the difference between how the epic link is created vs a regular link?

Is there something I should be doing in my script before trying to search for the link?

Below is what I'm using the iterate through the links. I did check the outward links as well, putting debug statements in and running it when creating manually, shows the user story is an inward link.

List<IssueLink allInIssueLink = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getID())

for (Iterator<IssueLinks> inIterator = allInIssueLink.iterator(); inIterator.hasNext();_
{
IssueLink issueLink = (IssueLink) inIterator.next()
def linkedIssue = issueLink.getSourceObject()

if (linkedIssue.issueTypeObject.name == "User Story")
{
userStory = linkedIssue
}
}

When I add the update issue event to the listener and update the issue created during the import, the script executes and finds the link no problem. 

Thanks in advance for any help.

1 answer

1 accepted

0 votes
Answer accepted
Ilya Turov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2019

I believe, when you import links as well as issues from CSV it makes it in two steps: first importing (creating) issues, then importing(creating) links.

So, if listeners listens only to "Issue Created" event, there's no link to find after step one. Maybe, try adding IssueLinkCreatedEvent to list of events listeners listens to.

Scott Boisvert
Contributor
June 17, 2019

That worked! Now I just have to figure out to limit to the import.

Suggest an answer

Log in or Sign up to answer