Hey guys, someone could help me with codes/tips/whatever pls ?
I'm trying to copy the Wiki Page link (Confluence link) to a Custom Field named Wiki Page. Trying to do it with Listener.
I was able to retrieve the remote link, but I cannot set it into the CF. Following the script and the error as well.
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.ListLinks")
log.setLevel(Level.DEBUG)
//-------------------------------------------------------------------------------------------------------------------------------------------
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.*
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.MutableIssue
def issue = event.issue as MutableIssue
def cfManager = ComponentAccessor.getCustomFieldManager();
def ilkManager = ComponentAccessor.getIssueLinkManager();
def changeHolder = new DefaultIssueChangeHolder();
def RemoteLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager)
def linkBuilder = new RemoteIssueLinkBuilder()
def remoteLinks = RemoteLinkManager.getRemoteIssueLinksForIssue(issue)?.collect {"From Application ${it.applicationName}, Title ${it.title}, URL: ${it.url}"}?.join("<br>")
RemoteLinkManager.getRemoteIssueLinksForIssue(issue).findAll {
it.applicationType == RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE
}.each {WikiPageLink ->
def cfWikiPage = cfManager.getCustomFieldObjects(issue).find {it.name == "Wiki Page"}
cfWikiPage.updateValue(null, issue, new ModifiedValue(cfWikiPage, remoteLinks),changeHolder)
// issue.setCustomFieldValue(null, issue, new ModifiedValue(WikiPageLink2, cfWikiPage),changeHolder)
log.debug("Wiki Page = " + remoteLinks)
}
Any help is welcome.
Thanks all.
Cassio.
