Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Sent notification custom field value hasn’t been provided within 5 calendar days of creation of task

Omprakash Thamsetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2023

How to send email notification to 2 users if the custom field value hasn't been provided within 5 calendar days of creation of task. 

 

I have a script runner plugin so open to use any solution like script listener or Jobs. 

Any advice would be greatly appreciated.

 

Thanks,

Om.

1 answer

0 votes
Kai Becker
Community Champion
August 16, 2023

Hi @Omprakash Thamsetty 

thanks for your question. This is something I would usually achieve using Automation rules.

If you want to use ScriptRunner, Jobs would be the recommended way to go. There you would configure a scheduled job that scans periodically.

In the script part you would need to search for issues in your project with that field missing.
After that, check each returned issue for your field and sent an email to the users.

I would recommend browsing through the Adaptavist Script Library to get a little inspired  🙂

Omprakash Thamsetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2023

I just tried finding the tickets which are missing the value even after 5 days.

 

Using Jobs in script runner. 

 

JQL query that I am using.

project = PROJ-A AND issuetype = "Change Request" and "Estimated hours)" is empty and (createdDate <=startOfDay(-4d) and createdDate >= startOfDay(-5d))

 


import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.mail.Email

import com.atlassian.mail.server.MailServerManager;

import com.atlassian.mail.server.SMTPMailServer;

import com.atlassian.mail.queue.MailQueue

import com.atlassian.mail.queue.SingleMailQueueItem

MailServerManager mailServerManager = ComponentAccessor.getMailServerManager()

SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()

if (mailServer) {

////////////////////Set the Email Variables//////////////////////////////////

    ///////TO: Email Address////////

    def ToEmailAddr =  "firstname.lastname@email.com"

   

   // def ToEmailAddr = issue.assignee.emailAddress

    Email email = new Email("" + ToEmailAddr)

    ///////FROM: Email Address////////

   

        email.setFrom("DoNotReply@jira.com")

   

   

        ///////Email Subject////////

        email.setSubject("($issue.key) - $issue.summary")

       // email.setCc("firstname.lastname@email.com")

        email.setCc("firstname.lastname@email.com")

     ///////Set the Email Mime Type/////  

        email.setMimeType("Text/Plain");

       

    ///////Email Body////////  

    String content

 

    content=  "Dear "

     content =  content+  

                   "\n"

    content =  content+

                      "Your ticket ($issue.key) Estimated hrs(Vendor) hasn’t been provided within 5 calendar days of creation"

 

    content =  content+

       

            "\n\n\nSincerely,"  +

            "\n" +

            "Jira Admin"

    email.setBody(content)

    ///////SEND Email ////////

    SingleMailQueueItem smqi = new SingleMailQueueItem(email);

    ComponentAccessor.getMailQueue().addItem(smqi);

     

  }else {

   log.error "No SMTP mail server defined"

}
Like Kai Becker likes this
Kai Becker
Community Champion
August 16, 2023

Hi @Omprakash Thamsetty 

you need to search for the issues in the groovy script. So you will need to build in something like this:

Issues.search('PUT YOUR JQL HERE').each { issue ->
// your email logic is triggered here
}


Your JQL looks a little wrong I think. The Esitmated hours part needs a fix for the  parentheses and I'm not sure about your project key, but this might be an example? 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.20.15
TAGS
AUG Leaders

Atlassian Community Events