Update Custom Date field with Due Date from Linked Issue

Drishti Maharaj
Contributor
September 5, 2022

Hi,

Is it possible to use a listener to update a Custom Date Field with the Due Date, but the Due Date information is on a ticket that relates to the main ticket?

Example:

- IssueA has the custom date field

- IssueB is linked to IssueA (relates to) and IssueB has the Due Date field filled in

- Want to automatically copy the date in the Due Date field from IssueB to the custom date field present in IssueA

 

Would that work with regards to the linking/relates to aspect?

 

I have this script which I used previously to update a date field but unsure how to modify the script to full the "Due Date" from the linked/relates to issue.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.link.IssueLink;

def issue = event.issue

def issueLink = ComponentAccessor.getIssueLinkManager()

 

// the name of the custom field to update
final customFieldName = 'FieldA'

// the new value of the field
final newValue = linkedissue.dueDate //This is where I am struggling

def customFieldManager = ComponentAccessor.customFieldManager

def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField : "Could not find custom field with name $customFieldName"

customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), newValue), new DefaultIssueChangeHolder())

 

Thanks.

2 answers

1 vote
Julien Peyrade _ Elements
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 6, 2022

Hello @Drishti Maharaj 

If you don't mind testing an add-on, Elements Copy & Sync lets you do exactly that.

Full disclosure, I'm the Product Manager of the app.

With our fields mapping, you can copy anything you want from an issue to another issue, including a Date Custom Field into the Due date.  

As a bonus, you can keep this value synchronized, so if you change it in the original issue it can change automatically in the copied issue.

The app is free for 30 days, (and stays free if your instance is under 10 users), so feel free to give it a try, and don't hesitate to tell reach our Support if you have any question.

Kind regards,

Julien

0 votes
Lukasz Grobelny
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.
September 5, 2022

Shouldn't automation be able to handle this?

Drishti Maharaj
Contributor
September 5, 2022

Hi, I assume I can have the trigger where the issue is created/update and then "edit issue" to update the custom date field. However, I am a bit unsure how to get the value of the Due Date from the linked issue itself?

Lukasz Grobelny
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.
September 6, 2022

Can you describe in detail how it should work?

Issue A has the custom field

Issue B has the Due Date

When would you like to copy this? When the Due Date is entered in B, the value will be moved to A?

Drishti Maharaj
Contributor
September 6, 2022

So going forward yes, when the Due Date is entered in B, it should be copied over to the field in A.

However, we have about 100 issues already that need to be updated first.

B already has the Due Date field filled in and want to copy that info across to the custom field in A so was trying to find a way to do this automatically for the existing issues first.

Lukasz Grobelny
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.
September 6, 2022

For the old issues - you can either create a script that would iterate through them,  copy this manually or add it in the CSV - download the one with the field with the date and upload - but you would need issue keys

Lukasz Grobelny
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.
September 6, 2022

I can check this script, just let me know what's wrong 

Drishti Maharaj
Contributor
September 6, 2022

Thanks @Lukasz Grobelny , this is what I get -  the error is on line 15 - not too familiar on how to manipulate the script to cater for the linked issues itself?

1.png

Lukasz Grobelny
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.
September 6, 2022

Will try to check this tomorrow if that's ok with you :) 

Drishti Maharaj
Contributor
September 6, 2022

Perfect. Appreciate the help @Lukasz Grobelny 

Ryan Angel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 6, 2022

It is created at the timing when the custom field is needed, such as when the WBS or Gantt chart screen is displayed for the first time or when the setting screen is displayed.

Even if these custom fields are deleted, they will be created again when WBS Gantt-Chart for Jira needs that custom field.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events