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

Scriptrunner Call a Script from Within a Script

David Harkins
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 25, 2021

We have a script that is run when an Issue created.

This takes the Organization value and updates a number of other fields, mainly Insight files to pull through more details about the organization.

We also now have another script which is run when the issue updated and can detect that the Organization filed has been updated.

Can we get the 2nd script to call the 1st script, passing the updated issue number, so that the corresponding fileds are updated?

1 answer

1 accepted

1 vote
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 28, 2021

Hi @David Harkins 

I think the easiest way to achieve this is to create a separate class rather than an embedded script.

You can create a script class and put it under scripts/groovy/util folder. Below is the sample greet function in MyGroovyClass.groovy file.

package mypackage

public class MyGroovyClass {
public static String greet(String name) {
return "Hello " + name
}
}

Then you can call this within other scripts

package mypackage


import mypackage.MyGroovyClass
def greetMessage = MyGroovyClass.greet("David Harkins")
log.info (greetMessage)

 

I hope this would shed a light on your need.

Cheers

Tuncay

sathish kumar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 23, 2024

@Tuncay Senturk , 

your approach helped me a lot, Thanks for this useful snippet.

would like to check instead of using the call approach, can you also please let us know how to achieve with simple def instead of class approach.

waiting for your valuable response :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events