Get issuelinks as customfield using java script


i’m trying to get the “issuelinks” as custom field and I didn’t succeed.

I’m using the following code:
var customfield_RDissuelinked; if (issue.fields.issuelinks && issue.fields.issuelinks.length > 0) { var issuelinks = issue.fields.issuelinks; for (var i = 0; i < issuelinks.length; i++) { var issuelinked = issuelinks[i]; if (issuelinked.type) { if (issuelinked.type == 'is caused by') {customfield_RDissuelinked = issuelinked.inwardIssue.key;} } } }

and I have the following fields structure in the ticket:

could you please help?