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?
I will try both methods. Hopefully there is no delay when using SR and field is updated immediately.
Regards,
Sunil
Hi @Kumar_ G Sunil
After checking, please let us know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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()))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.