Forums

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

how can i get the value of custom field using groovy

t April 7, 2015

i want to get the value of 'date received' and then find out how many days between that date and the date the status changed to resolved.

 

How can i do this? i found one bit of code but it calculates the days between someone was assigned and resolved and i cant get it to work with custom fields.

5 answers

0 votes
AndrewB
Contributor
September 24, 2015

How to get the "date received" value:

CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
  
CustomField dateReceivedField = customFieldManager.getCustomFieldObjectByName("date received");

def dateReceived = issue.getCustomFieldValue(dataReceivedField)

 

issue.resolutionDate.getTime() will give you when the "resolution" was set. If you want when it was last transitioned into "Resolved" status then you will need to use ChangeHistoryManager - there are some nice examples here https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted+Fields - pretty much everything you need is on that page, just need to piece it together.
0 votes
t April 13, 2015

can anyone help at all please? need to get this sorted asap as its one of the conditions that need to be fixed in order for pilot of jira to be successful! arghhhhhh damn my inability to code with jira

0 votes
t April 12, 2015

Cant seem to figure this one out, im guessing because i dont know how to correctly call a custom field as well as that particular custom field being a date and not time..

0 votes
t April 8, 2015

(issue.resolutionDate != null) ? String.format("%d day(s)",(int)((issue.resolutionDate.getTime() - issue.getCreated().getTime()) /(1000*60*60*24))) : "N/A" ; That is the code i found online but it seems to only work for when an issue is assigned.. and it compares it from assigned to resolved.. i want to change that so it gives me the number of days from the date of the custom field 'date received' till the date the status changes to resolved

0 votes
JamieA
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.
April 7, 2015

Can you paste the code that you have so far?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events