Get the Date/Time When a Custom Field Was Set to "Yes"


I have a custom "Field A" that needs to be populated with the date/time when another custom "Field B" was set to "Yes".

I need to create a script that:

  1. Runs a JQL to filter all the issues that have "Field B" set to "Yes"
  2. Get the date/time when the user selected "Yes"
  3. Add this information to "Field A"

Any ideas?

2 answers

This is what I have so far:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def query = jqlQueryParser.parseQuery("myJQL")
def results =, user, PagerFilter.getUnlimitedFilter())

results.getIssues().each {
//code to get date/time when "Field B" was set to "Yes"
//code to add the date/time to "Field A"
0 votes
Gaston Valente Community Champion Jul 25, 2017


I think there's no direct way, you need to query the rest api for the changelog of every issue, check the modifications and derive the date from this information.

then you can add the date to another field for querying



Thanks Gaston,

In this case you would do everything with REST API, get the information and update the tickets? Or you would get the information with REST API and update the fields with ScriptRunner?


Gaston Valente Community Champion Jul 25, 2017


it depends on your needs, for example if I need to record the first date that the field changed:


  1. create a service in script runner to query by jql all the issues with the field in yes and the date empty
  2. loop the issues from the result set and update the date field with the changelog


Gaston Valente Community Champion Jul 25, 2017

If you need to get the date value right away I'll do the same but with a listener and only the current issue 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

445 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you