Hi all,
Had a couple questions with script runner. I know (and use) transition validation scripts like the example below:
issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate')
..but how can I require that the link also be limited to a specific issue type? Such as 'Bug'?
My other question is that I've noticed that the transition validation example above works fine if the link is set earlier in the workflow. *However* -- if the transition that has the validation script also has a transition screen with an issue link field, and the user uses that field, the validation script doesn't notice it, and prevents progression in the workflow. Ideally I'd like to make it so the user can add the required field if necessary with in the transition screen itself without backing out and trying the transition again.
Would the solution be to set up a behavior? Guessing I could use same validation script above?
Any tips appreciated!!
You can get the issuetype of the linked issue like this
issueLink.destinationObject.issueTypeObject.name
issueLink is one entry of the list you get from getOutwardLinks().
For your second question look here: https://answers.atlassian.com/questions/139592/check-for-duplicates-link-in-groovy-transition-validation-script
Henning
Not sure what you mean by "validate", but you can get those links via the RemoteIssueLinkService. E.g.
remoteIssueLinkService.getRemoteIssueLinksForIssue(user, issue)?.remoteIssueLinks
to get all remote issue links of an issue.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you know the pageid of the Confluence page (–> select Page Information menu item and take a look at the URL) you could use following method.
boolean hasRemoteConfluenceLink(ApplicationUser user, Issue issue, String pageId, Logger log = null) { def conf_link = applicationLinkService.getApplicationLinks(ConfluenceApplicationType)?.first() if (!conf_link) { log?.error "No confluence application link found." return false } def globalId = "appId=$conf_link.id&pageId=$pageId" return remoteIssueLinkService.getRemoteIssueLinksForIssue(user, issue)?.remoteIssueLinks?.globalId?.contains(globalId) }
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank a lot for response,
But I want a global script just asking for a link of confluence or web link.
Is there any other way like below script... so that it throws an error and should ask for the link.
because we just can't do every confluence page id and keep on updating the script.
issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate')
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, if you take a look into the API you could see there are some methods to get information from a RemoteIssueLink, e.g. getApplicationType() which should return "com.atlassian.confluence" (or better RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE) for confluence links. Using this the method from above could be adapted to check for any Confluence link.
import com.atlassian.applinks.api.ApplicationLinkService import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType import com.atlassian.jira.bc.issue.link.RemoteIssueLinkService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.RemoteIssueLink import com.atlassian.jira.user.ApplicationUser import org.apache.log4j.Logger static boolean hasAnyRemoteConfluenceLink(ApplicationUser user, Issue issue, Logger log = null) { def applicationLinkService = ComponentAccessor.getComponent(ApplicationLinkService) def remoteIssueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService) def conf_link = applicationLinkService.getApplicationLinks(ConfluenceApplicationType)?.first() if (!conf_link) { log?.error "No confluence application link found." return false } return remoteIssueLinkService.getRemoteIssueLinksForIssue(user, issue)?.remoteIssueLinks?.any{it.applicationType == RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE} } hasAnyRemoteConfluenceLink(ComponentAccessor.jiraAuthenticationContext?.loggedInUser, issue)
(Not tested, take care of this by yourself. Please be aware that this takes the current user into consideration and what this user is able to see.)
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I'm trying to find a script that returns the a confluence link if contain 'closure report'.
Could this script be adapted todo this?
Many Thanks
Kevin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.