Forums

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

Update Date/Time field value on cloud using in build function

Kumar_ G Sunil October 20, 2025

Hello Everyone,

 

We’re trying to update a custom field by adding 2 days to the current timestamp using a post function. We cannot use JMWE or Automation for Jira because the field becomes read-only immediately after the transition, which causes delays in execution.

We’ve noticed that using %%CURRENT_DATETIME%%+2d sets the value instantly during the transition but isn't wokring. Is there a recommended way to use this expression in a post function to ensure the field is updated before it becomes read-only?

 

 

4 answers

0 votes
Kumar_ G Sunil October 20, 2025

I will try both methods. Hopefully there is no delay when using SR and field is updated immediately.

 

Regards,
Sunil

Gor Greyan
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.
October 20, 2025

Hi @Kumar_ G Sunil

After checking, please let us know.

0 votes
Gor Greyan
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.
October 20, 2025

Hi @Kumar_ G Sunil

Please try the following script in the post-function, putting it before the re-index step.

import java.time.*
import java.util.*
import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Your Date Field")
def newDate = LocalDate.now(ZoneId.systemDefault()).plusDays(2)
issue.setCustomFieldValue(cf, Date.from(newDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))

0 votes
Taliah15
Contributor
October 20, 2025

Hello @Kumar_ G Sunil 

To update your custom field by adding 2 days during a post function, using %%CURRENT_DATETIME%%+2d alone won't work as expected in Jira's built-in expressions. A crisp way is to use a scripted post function (like ScriptRunner) where you can programmatically add 2 days to the current date and set the field value right in the transition, ensuring it happens before the field locks as read-only. This guarantees instant updating without delay, bypassing the limitations of JMWE or Automation. Let me know if you want a sample script snippet for that! If it works kindly plz let me know. 

0 votes
Trudy Claspill
Community Champion
October 20, 2025

Hello @Kumar_ G Sunil 

How is the field being made read-only?

Kumar_ G Sunil October 20, 2025

Script Runner Behaviours.

 

Suggest an answer

Log in or Sign up to answer