Groovy Script Runner: Custom Parameters for Custom Scripts

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

This widget could not be displayed.

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?

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

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

It needs to have the @ScriptListener annotation for listeners.

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

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?

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.

I'll try to repro later.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

533 views 3 19
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you