It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Check for pre-existing duplicate links in the issue (on resolve)

Kevin Bushman May 08, 2017

Hi there, we have a script that was not written by me but is pretty slick in that it will check for pre-existing duplicate links in the issue and then check for new duplicate links in the current screen. 

Since we migrated to Jira 7+, the check for existing duplicates part of the script is no longer working. It seems like some kind of aspect of our script has been deprecated but I'm a little confused by the jira documentation. I'm not 100% clear what I need to change to the below portion. 

def linkManager = ComponentManager.getInstance().getIssueLinkManager()

// Check for pre-existing duplicate links in the issue
if (linkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate')) {
    dupeLinkCount += 1
}

^ Gives us the following error:

`Script function failed on issue: KBSHARFILE-21, actionId: 31, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.ComponentManager.getIssueLinkManager() is applicable for argument types: () values: []
at Script92.run(Script92.groovy:28)`

 

Full script:

def dupeLinkCount = 0

def linkManager = ComponentManager.getInstance().getIssueLinkManager()

// Check for pre-existing duplicate links in the issue
if (linkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate')) {
    dupeLinkCount += 1
}

// Check for new duplicates links in the current screen
def request = webwork.action.ActionContext.getRequest()
if (request) {
    def linktype = request.getParameter('issuelinks-linktype')
    def linkedIssue = request.getParameter('issuelinks-issues')
    if (linktype == 'duplicates' && linkedIssue) {
        dupeLinkCount += 1
    }
}

def resolutionIsSetToDuplicate = issue.getResolution().getName() == "Duplicate"
def noDuplicateLinks = dupeLinkCount == 0

if ( resolutionIsSetToDuplicate && noDuplicateLinks ) {
    invalidInputException = new InvalidInputException("If you are closing this issue with resolution Duplicate, please add a \"duplicates\" link at the bottom of this form.")
    invalidInputException.addError("issuelinks", "Please pick  \"duplicates\" from \"Linked Issues\" selection.")
}

1 answer

1 accepted

1 vote
Answer accepted

Hi Kevin,

Replace : 

def linkManager = ComponentManager.getInstance().getIssueLinkManager()

With:
def issueLinkManager = ComponentAccessor.getIssueLinkManager()

Let me know how you get on.

Thanks,

Johnson Howard

Kevin Bushman May 09, 2017

That did the trick. Thanks Johnson!

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar invitation: Generate custom Jira Cloud PDF reports and exports

Jira may be a staple part of your workday, but your colleagues, customers, business partners or an auditor might need information presented in a different format, that is easy to access and read. And...

61 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you