Getting date value from a custom field during close transition

Hi everybody,

 

I'm working with two workflows, one for main JIRA and one for subtasks.

When I close a subtask I have a screen that ask the user to complete a date field.

I would like the value of this date field to be "injected" in another date field in the main JIRA.

I wrote a post script function that doesn't work. Can you please give me some help?

Here is the code:

 

//Imports nécessaires
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
MutableIssue parentIssue = issue.getParentObject() as MutableIssue
def cfSendingSFD = customFieldManager.getCustomFieldObjectByName("Deadline for sending the SFD")
def cFieldSendingSFD = customFieldManager.getCustomFieldObject("customfield_10801")
def cField = issue.getCustomFieldValue(cFieldSendingSFD)
parentIssue.setCustomFieldValue(cfSendingSFD, cField)

 

Thanks in advance.

 

Germain.

1 answer

1 accepted

This widget could not be displayed.

Try this, this should do the trick

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
MutableIssue parentIssue = issue.getParentObject() as MutableIssue
def cfSendingSFD = customFieldManager.getCustomFieldObjectByName("Deadline for sending the SFD")
def cFieldValue = issue.getCustomFieldValue(cFieldSendingSFD)
cfSendingSFD.updateValue(null, parentIssue, new ModifiedValue(null, cFieldValue), new DefaultIssueChangeHolder())

 

Tarun Sapra Community Champion Dec 14, 2017

I am assuming on both issue and parent issue the date field is "

"Deadline for sending the SFD"

if it's not then in code you will need to add one more line

def anotherDateField= customFieldManager.getCustomFieldObjectByName("Main jira date field here")

 and then the last code line will be

anotherDateField.updateValue(null, parentIssue, new ModifiedValue(null, cFieldValue), new DefaultIssueChangeHolder())  

Hi Tarun,

 

The two fields have different title, so I used your last modification.

It works like a charm!

Thanks for your precious help (as usual)!

 

Regards,

 

Germain.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 14 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

41 views 1 0
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