I am trying to setup a service to send out emails based on a JQL. Followed the instructions mentioned here: https://scriptrunner.adaptavist.com/latest/jira/services.html
Now we need to make this generic so that it can be set up to run for multiple different filters. Currently the groovy file that has an hard coded JQL.
So the question is:
1) How do i pass the filter id to the groovy file when setting up the service?
2) What should the script look like after the Point 1 above is answered? Here is how my current code looks like:
//Get the SearchRequestManager
def searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager) //Find the filter using the SearchRequestManager
def filter = searchRequestManager.getSearchRequestById(10001)
//Get the jql query
def jqlQuery = filter.query
You can't pass a parameter to a groovy script from any of the scriptrunner interfaces.
One thing you could do is transform your script into a class with a method that accepts a JQL or filterId. Then for each instance of the service, you want to create you have a separate script that imports your class above and calls the method with the desired argument.
Something like this:
YourEmailService.groovy
public class YourEmailService{
void sendMailForFilter(filterId){
def searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager)
def filter = searchRequestManager.getSearchRequestById(filterId)
//etc
}
}
EmailserviceFilter10001.groovy
import YourEmailService
YourEmailService.sendMailForFilter(10001)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.