The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to automatically set the date in calendar ?

Alex
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 Champions.
August 18, 2022

how to automatically set the date (deadline) in cf "deadline" = (creation date +14 days)
my code in post-function.. no work

import com.atlassian.jira.component.ComponentAccessor

import java.sql.Timestamp

def versionManager = ComponentAccessor.getVersionManager()

def projectComponentManager = ComponentAccessor.getProjectComponentManager()

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def userUtil = ComponentAccessor.getUserUtil()

// a date time field - add 14 days to current datetime

def dateCf = customFieldManager.getCustomFieldObjectByName("my_deadline") // Date time fields require a Timestamp

issue.setCustomFieldValue(dateCf,{{now.plusBusinessDays(14)}})

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

3 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
August 19, 2022

Hi @Alex

I have provided a solution for this in this link https://community.atlassian.com/t5/Jira-Service-Management/how-Add-to-my-cf-calendar-14-days/qaq-p/2111753#M112706

I hope this helps to solve your question. :)

Thank you and Kind regards,

Ram

Alex
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 Champions.
August 19, 2022

Thank you!!! It’s working 

0 votes
Tansu Akdeniz
Community Champion
August 18, 2022

Hi @Alex 

The following smart value should be used within Automation. Do you have it?

{{now.plusBusinessDays(14)}}

If yes, please go to project -> project settings -> automation and add new rule. Then, choose the trigger (ex; issue created) and edit your custom field with it.

Check this answer also.

Alex
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 Champions.
August 18, 2022

Hi! @Tansu Akdeniz  

hmm, I don't have automation, I'm writing a script from scratch..

Tansu Akdeniz
Community Champion
August 18, 2022

Got it. Please check this page also.

Sample;

issue.setCustomFieldValue(dateCf, new Timestamp((new Date() + 14).time))
TAGS
AUG Leaders

Atlassian Community Events