Comparison between two Custom field type Date fields

Hello there,

I want to display a result in the format of label or text box between two date comparison fields.
Ex: Planned Production Date and Actual Production Date are two fields.
Label X = Actual Production Date - Planned Production Date. Result should be shown in Days.

With that result we need to generate a report and send to our manager.

Hope my request is clear.

I have tried scipted fields but i didnt get what I am looking for. :(

Thanks in advance,
Jana

2 answers

1 votes
Jeremy Mooiman Community Champion Jul 21, 2017

Dear Jana,

Trying to understand your exact question here :-), we will figure it out.

You have two ''date'' custom fields, and you want to show the value of such field. Correct?

Or do you have labels in your custom fields that you want to search for?

Friendly Regards,

Jeremy

I got the answer to represent in number of days but if if I want to represent in color code, what could be best way?

With the following code i have got it but if instead of number if I want to get in color code like if the value is Negitive then Red if postive then Green? Is it possible to achive this?

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import java.util.Date.*

def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObject('customfield_19400');

def dateFieldObject2= customFieldManager.getCustomFieldObject('customfield_23302');

if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2)) {
def dateValue= issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2= issue.getCustomFieldValue(dateFieldObject2) as Date
return dateValue - dateValue2
}

I got the answer to represent in number of days but if if I want to represent in color code, what could be best way?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,119 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot