Hi everyone,
I would like to send a mail with a link of the current board.
I'm using scriptrunner but I m not able to find the current id or url...
Can anyone help me?
Hi @Tommaso Scorteccia
For your requirement, you can try to trigger the email using the ScriptRunner console with something like this:-
import com.atlassian.greenhopper.service.rapid.view.RapidViewServiceimport com.atlassian.greenhopper.web.rapid.view.RapidViewHelperimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.mail.Emailimport com.onresolve.scriptrunner.runner.customisers.JiraAgileBeanimport com.onresolve.scriptrunner.runner.customisers.WithPluginimport groovy.xml.MarkupBuilder@WithPlugin("com.pyxis.greenhopper.jira")@JiraAgileBeanRapidViewService rapidViewService@JiraAgileBeanRapidViewHelper rapidViewHelperdef loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef applicationProperties = ComponentAccessor.applicationPropertiesdef hostUrl = applicationProperties.getString('jira.baseurl')def views = rapidViewService.getRapidViews(loggedInUser).valuefinal def projectKey = 'MOCK'def emailBody = new StringWriter()def html = new MarkupBuilder(emailBody)html.html { body { views.each { if (it.name == "${projectKey} board") { a ( href : "${hostUrl}/secure/RapidBoard.jspa?rapidView=${it.id}&projectKey=${projectKey}") { mkp.yield "Link to ${projectKey} board" } } } }}final static creatMessage(String to, String subject, String content) { def mailServerManager = ComponentAccessor.mailServerManager def mailServer = mailServerManager.defaultSMTPMailServerdef email = new Email(to) email.setSubject(subject) email.setMimeType("text/html") email.setBody(content) def threadClassLoader = Thread.currentThread().contextClassLoader Thread.currentThread().contextClassLoader = mailServer.class.classLoader mailServer.send(email) Thread.currentThread().contextClassLoader = threadClassLoader}creatMessage('user@samplemail.com', 'Board Link', emailBody.toString())
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to modify it accordingly.
Below is a print screen of the email link received:-
Upon clicking the link, the receiver is re-directed to the board. However, you must ensure that the receiver has the required permission to view the board.
I hope this helps to answer your question.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ , thank you for the example
I'm trying your script, but my board structure is quite difference, I have a one project with different board inside. For example
Project "Apple"
Boar "Develop Board"
Board "Testing Board" and so on..
I see that to identify the board you use the condition
if (it.name == "${projectKey} board")
but I can't use this condition for my scope
What i want to do is a button in the board that send a link like window.location.href in javascript, or a function like "getcurrentboard"
Thank in advance
It looks like you're new here. Sign in or register to get started.