Forums

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

Need to send custom email to the users when the ticket has aged 20 days

Naveen kumar April 22, 2025

Need to send custom email to the users when the tickets in certain projects has aged 20 days . This is to alert the POC management that the tickets are aged and not worked. I have script runner plugin and im trying to achieve using listener and behaviour. yet nothing works. Any guidance might help here (with the code) . I don't have automation plugin. 

2 answers

2 votes
John Funk
Community Champion
April 22, 2025

Hi Naveen,

If you are using Cloud, which the deployment type above says that you are, then you can create an automation rule to easily do this. 

 

Naveen kumar April 23, 2025

We are using JIRA data center . So we dont have automation plugin. But we do have scriot runner so would be nice if you could help me with this plugin.

John Funk
Community Champion
April 23, 2025

Sorry, I do not have expertise with ScriptRunner. 

1 vote
Trudy Claspill
Community Champion
April 22, 2025

Hello @Naveen kumar 

Can you clarify for us if you are using Jira Data Center (self-hosted) or Jira Cloud (SaaS)? Go to the Help button near your avatar. Click it then click the About option? What information do you see?

What level of access do you have? Are you a Jira Administrator, and administrator for the on project, or a user with no administrator access?

The Automation for Jira functionality should be available. It is available in all Jira Cloud instances, and started being included in Jira Data Center with version 9.x, I believe. But you may not have access to create Automation Rules if you don't have appropriate admin access.

If you have tried to do this with ScriptRunner, please share the details of what you have tried including the configuration and scripts.

Naveen kumar April 23, 2025

We are using JIRA Data center and im a JIRA Administrator . We are currently using 8.22.6. 

Things i have tried to trigger the email using listeners:

First script: 

import com.atlassian.jira.component.ComponentAccessor

//Define the current Issue and the desired Custom Field Name
def issue = event.issue
def customFieldName = 'Date checker 8'

//Define Change History Manager and retrieve the last updated item for this issue
def changeHistoryManager = ComponentAccessor.changeHistoryManager
def lastChangedItem = changeHistoryManager.getAllChangeItems(issue).last() as String

//Then check if the latest update to the Issue had a change to this Custom Field
if (lastChangedItem.contains(customFieldName)) {
    //Add code to be executed if this condition is met

    //For example, if the Custom Field is a certain value
    def customField = ComponentAccessor.customFieldManager
    def customFieldObject = customField.getCustomFieldObjectsByName(customFieldName).first()
    def customFieldValue = issue.getCustomFieldValue(customFieldObject) as String

    if (customFieldValue == '7') {
        //Execute further code, for example, send a log message
        log.warn("The Custom Field $customFieldName has a value of $customFieldValue")
    }
}
Option selected : Send custom email based on events
Event selected : All issue Events and Issue Updated
Projects selected: Only two projects.
Script 2 : 
cfValues['Date checker 8'] == '7'
Option selected : Send custom email based on events
Event selected : All issue Events and Issue Updated
Projects selected: Only two projects.
Script 3: I tried set a calculated scripted field to calculate the ageing of the ticket based on created date and tried to copy the field value to another created number field using behaviour. Then using listener setting up the above script to trigger the alert (What i thought was listener was not working on calculated scripted fields)
At the end none of them worked for me so came to community to ask for assistance. im actually at the dead line.
Trudy Claspill
Community Champion
April 23, 2025

This would be a very simple task to complete with Automation for Jira. Have you considered installing the plugin? It is free, and provided by Atlassian.

You would have to install a version that is compatible with your version of Jira DC.

Naveen kumar April 23, 2025

We cant install anymore plugin due to management. so if its possible to achieve in script runner can you help me please

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events