Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,432
Community Members
 
Community Events
168
Community Groups

Update Custom Date field with Due Date from Linked Issue

Edited

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

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

Shouldn't automation be able to handle this?

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?

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?

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.

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

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

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

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

Perfect. Appreciate the help @Lukasz Grobelny 

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

Atlassian Community Events