Hi Atlassian Community,
Please note that the last answer posted from me is the correct coding...however, I wanted to give @Max Lim _ScriptRunner_ credit for actually answering sooo...if you are trying to do something similar, look at the last coding block.
Alrighty...let me see if I can describe this well enough to get some ideas/assistance.
We have put together a Support Request issue type that is created and auto linked from a projects Epic (using a combo of ScriptRunners fragments/behaviours). Thought process behind this was since these requests will happen mainly during Quarterly Planning and Epics are how we capture 'ideas of work', that it makes sense to send out these requests and link them to the Epic body of work. Our workflow allows the teams to kick it back to each other for more info as needed as well as accepting/rejecting the request. We then can run a nice filter to show interdependency, timliness of requesting support, etc, etc. 
Once the Support Request is approved, it auto creates a task in the supporting teams project and another link is created to the originating Support Request.
From there they can keep it as a placeholder task OR move it to whatever it will require work wise...ie Story if the support includes any development. 
Now, we are looking to somehow take the original Epic and do the following:
- add the Epic link in which the Support Request (SR) was created from, to the resulting support task
- automatically add the resulting SR task as a child of the Epic in which the Support Request was created from (ultimately this is what we'd like to do since the Team requesting support will be listing the resulting Task or work in their Release scope)
Right now the way it is set up, you have to manually click back 2 links to find the originating Epic and manually connect the two via a link. I can't for the life of me wrap my head around how exactly to automate this so that Teams don't have to follow the breadcrumbs back to the originating Epic.
I have found code to copy or add from the original issue to the linked issue, but not through 2 links. I've tried copying the epic link when cloning...and this does work, but the link doesn't make sense on the resulting task. I've also tried creating a parent hierarchy scripted field using a built in SR function and tried to copy this field over during the clone post function - this doesn't work since the scripted field is looking at the first link and hence will not copy over.
Any ideas would be most helpful!