Confuence links are shown as "mentioned in" links in Jira issue. I want to restrict the workflow transition if the issue does not have "mentioned in" link with its issue key in the link.
Hi @Chaya
Usually Confluence links are recognize in jira as Remote Links, with this you can create a Scriptrunner Validator looking in the issue if it has some remote link nominate as Confluence and also look in the summary if have the issue key reference.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
// Get the current issue
Issue issue = issue
// Get the RemoteIssueLinkManager to fetch remote links
def remoteIssueLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager)
// Fetch all remote links for the current issue
List<RemoteIssueLink> remoteLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)
// Check if any remote link is of type "mentioned in" and contains the issue key
def hasMentionedInLink = remoteLinks.any { remoteLink ->
remoteLink.applicationName == "Confluence" &&
remoteLink.title?.contains(issue.key)
}
if (!hasMentionedInLink) {
// Block the transition if no valid "mentioned in" link is found
return false
}
// Allow the transition if a valid "mentioned in" link exists
return true
Let me know if this helps you.
Best Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Chaya
Usually confluence links are recognized as "Remote Links", you can create a Scriptrunner Validator to block the transition according your condition.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
// Get the current issue
Issue issue = issue
// Get the RemoteIssueLinkManager to fetch remote links
def remoteIssueLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager)
// Fetch all remote links for the current issue
List<RemoteIssueLink> remoteLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)
// Check if any remote link is of type "mentioned in" and contains the issue key, this second condition is optional, because the issuekey can be mentioned on the body of the page in confluence
def hasMentionedInLink = remoteLinks.any { remoteLink ->
remoteLink.applicationName == "Confluence" &&
remoteLink.title?.contains(issue.key)
}
if (!hasMentionedInLink) {
// Block the transition if no valid "mentioned in" link is found
return false
}
// Allow the transition if a valid "mentioned in" link exists
return true
Let me know if this helps you.
Best Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chaya,
You can try Advanced Compare Condition in automations. Check if the issue contains a "mentioned in" link using JQL or custom data.
Unfortunately, there is no built-in validator in Workflows for checking "mentioned in" links directly, so you need to use custom scripting or an add-on like ScriptRunner for Jira.
import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
// Get all the issue links for the current issue
def links = issueLinkManager.getOutwardLinks(issue.id)
// Check if any link is of the type "mentioned in"
def hasMentionedInLink = links.any { link ->
link.issueLinkType.name == "mentioned in" && link.destinationObject.key.contains(issue.key)
}
if (!hasMentionedInLink) {
return false // Block transition
}
return true // Allow transition
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.