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

Groovy Script Runner: Custom Parameters for Custom Scripts

Ruben Straube Aug 31, 2014

Hello,

I've created a script to send an E-Mail to watchers of the parent issue upon creation of a subtask. The script is based very much on the built-in SendCustomEmail.groovy; in fact, it is only an additional seven lines. (Why re-write functionality if you can use existing one.)

Unfortunately, the SendCustomEmail.groovy uses additional parameter fields that I cannot use. Is there a way to use custom parameters for custom scripts? Alternatively, if Jamie Echlin reads this: Do we have a chance of this functionality being built-in? I will happily send you those seven lines to add :-)

Kind regards

Ruben Straube

1 answer

0 votes
JamieA Sep 01, 2014

If you have subclasses the script or just copy and paste it you should see the parameters when you add it to a workflow. So I don't really get your question, if you could use the original why can you not use your copy?

> Do we have a chance of this functionality being built-in? I will happily send you those seven lines to add

Depends what the 7 lines are! What do they do?

Martin Sander Sep 01, 2014

> you should see the parameters when you add it to a workflow.

It is not added to a workflow, it is a "Script Listener" that should listen to the "issue created" event (If the created issue is a sub task, the watchers of the parent issue should be notified).

So we go to "Script Listeners" in the admin area, and no matter where we put our Listener, only the built-in ones are displayed. Choosing "Custom listener" does not give us the parameters we defined (obviously).

JamieA Sep 01, 2014

Well, what version of Script Runner are you using, and where are you putting it?

It needs to have the @ScriptListener annotation for listeners.

Ruben Straube Sep 01, 2014

To add to what Martin wrote:

Those lines are to use the parent issue's watcher field; it's a functionality we've been asked about a lot recently. I only added

else if (f == "parentwatchers") {
                    if(issue.isSubtask()) {
                        watcherManager.getCurrentWatcherUsernames(issue.getParentObject().genericValue).each { String username ->
                            addresses.add(userUtil.getUser(username).emailAddress)
                        }
                    }
                }

into the long if .. else if clause in the function getAddressesFromFields(...).

JamieA Sep 01, 2014

OK that's related to that other discussion? Can we keep that separate.

Again: Well, what version of Script Runner are you using, and where are you putting it?

Ruben Straube Sep 01, 2014

The full script is this one here: https://www.refheap.com/89702

Since the code is essentially the same as the SendCustomEmail.groovy with some additional lines and another class name, the annotation @ScriptListener is there.

The script runner version is 3.0.3. It doesn't matter if I put it into the scripts folder or paste it; the class is found, but I still get the same parameters as any custom script and not the same as for the custom email listener.

JamieA Sep 01, 2014

I'll try to repro later.

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...

60 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