Hello everyone!
I am new in Jira and groovy, and I need your help.
I want to get the time stamp of fixVersion field, if it is possible. The idea is to get all the stories and tasks where the fix version field was updated in the last 30 hours. I don't know if I'm right, and maybe my algorithm can be improved (maybe the JQL can be written differently?)
This is what I've got so far(not much):
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.issue.search.SearchQuery
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
def query = jqlQueryParser.parseQuery('project in (My_Project, Proj) AND issuetype in (Story, Task) AND updated >= -30h ')
def results = searchService .search(user,query, PagerFilter.getUnlimitedFilter())
results.getResults().each {documentIssue ->
//ver is array of fix versions
def ver = documentIssue.getFixVersions()
if(!ver.isEmpty()){
//do something
}
}
I've searched on the internet and couldn't find anything. I will really appreciate your help, thank you!
Hi @aviv_eldad
Welcome to the Community!
Your starting point is correct, there is no way to get an updated date/time for a specific field out-of-the-box in Jira. So, fetching the issues which were updated within the last 30 hours and then traversing their histories if the fix version field was updated within 30 hours makes sense.
Here is how you can fetch all changes in Fix Version field for an issue
List<ChangeItemBean> changeItems = changeHistoryManager.getChangeItemsForField(issue, Fix Version"));
'project in (My_Project, Proj) AND issuetype in (Story, Task) AND cf_fv_updated >= -30h '
assuming cf_fv_updated is the new custom field name which will hold the date/time value when an issue's fix version field is updated.
I hope it helps!
Tuncay
btw, I may be biased as I am one of the folks behind Enhancer Plugin. Please let me know if you need further assistance on both solutions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.