users want to order (so not filter) on a linktype. We want to have script in place that copies the value of the linktype ones it transitions into a custom field so we can use that for ordering.
is that possible?
Hi,
I guess you can use the "IssueLinkCreatedEvent" and adapt this script to your needs :
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
List<IssueLink> allInIssueLink = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId());
for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
IssueLink issueLink = (IssueLink) inIterator.next();
def linkedIssue = issueLink.getSourceObject()
def linkedIssueTypeName = issueLink.getIssueLinkType().getName()
log.debug("issueLink : " +linkedIssueTypeName
log.debug("linkedIssue : " + linkedIssue)
int cfId = 11001
def cf = customFieldManager.getCustomFieldObject(cfId)
def cfValue = issue.getCustomFieldValue(cf)
cf.updateValue(null, issue, new ModifiedValue(cfValue, linkedIssueTypeName), new DefaultIssueChangeHolder())
}
You can get the outward links similarly.
Antoine
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.