Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

How do I Call a User Defined method from a post function? Edited

I have a user defined function in a groovy script I keep in the Script Editor file list that I want to call from post function scripts also stored in the Script Editor list. My objective is to maintain one copy of the function that can be used across scripts (post functions).  I have included the method's declaration to simplify the discussion.

def TransitionLinkedIssues(com.atlassian.jira.issue.Issue issue, String targetLinkTypeName, String targetCategoryName, String targetTransitionName) {

...

}

2 answers

Hi @Jeff Abbott 

You should create a folder in the jira directory: "Scripts" and store the scripts there.

Then in the groovy using  the postfunctions or other you can call the function from using in the script.

import util. <your_groovy_name>
// and then call your function or method
<your_groovy_name> .functionName ()

I hope it helps you, you can find the documentation in Script Roots 

0 votes
tom lister Community Leader Jan 04, 2021

Hi @Jeff Abbott 

we store our util classes in Script Editor

image.png

Then access them from other other scripts

e.g. this is a workflow post function using the above

 

import com.cheil.retail.ShoptectConstants
import com.cheil.retail.ShoptectSubTaskHandler
import org.apache.log4j.Logger

def logit = Logger.getLogger("com.cheil.eu.logging")

ShoptectSubTaskHandler handler = new ShoptectSubTaskHandler(issue)
logit.info(handler)
handler.createSubTasks()

Suggest an answer

Log in or Sign up to answer
TAGS

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