Forums

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

Update Target Start field to Sprint Start date

Sadath Ali Syed September 28, 2021

We would like to have a post function to update 'Target Start' field to Sprint Start date. We are using 'Set field value (JMWE app)'. We are using Groovy expression - 'issue.get("Sprint")*.startDate.flatten()'. However, this is not updating the Target Start, probably due to date format miss match. Can someone help us.

1 answer

0 votes
David Fischer
Community Champion
September 28, 2021

Hi @Sadath Ali Syed ,

that expression returns an array of dates, which is not what's expected. Try this instead:

issue.get("Sprint")?.find{it.active}?.startDate

which will find the active sprint of the issue and then return that sprint's start date

Sadath Ali Syed September 28, 2021

@David Fischer - I did try the above. It gives below error:

An error occurred while executing a Set Field Value post-function: Field type com.atlassian.rm.jpo.customfields.baseline.start.BaselineStartCustomFieldType@cb91b52 of field Target start is not supported. : root cause: Field type com.atlassian.rm.jpo.customfields.baseline.start.BaselineStartCustomFieldType@cb91b52 of field Target start is not supported.

I think it is related to the date format of Sprint start vs the date format 'Target start' field 

David Fischer
Community Champion
September 28, 2021

Hi @Sadath Ali Syed ,

the problem is that the destination custom field is not a standard custom field but a field that belongs to Advanced Roadmaps. 

Can you share the full error (with stack trace) as found in the Jira logs?

Sadath Ali Syed September 28, 2021

-logs-

Sadath Ali Syed September 29, 2021

@David Fischer - Sorry to bother you. Just checking if above is the info you are looking for.

David Fischer
Community Champion
September 29, 2021

Hi @Sadath Ali Syed ,

sorry, my bad, the correct Groovy expression is:

issue.get("Sprint")?.find{it.active}?.startDate?.toDate()

The reason is that the Sprint start date is returned as a org.joda.time.DateTime object, whereas most Jira fields expect a java.util.Date object...

Sadath Ali Syed September 29, 2021

It worked !!! Thanks a million @David Fischer .

Kishore D
Contributor
July 8, 2022

Hi @Sadath Ali Syed  @David Fischer ,

I have created one script field with same groovy expression. But i dont see it reflecting in jira created.

should i try this with script filed (date type) ? or in different way?

Suggest an answer

Log in or Sign up to answer