It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
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
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).
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(...).
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.
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAtlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.