Please find the below scenario
we have two custom fields.
Field A the value = 2
Field B ( Date field)
Now i need to set the date ( exclude Saturday and Sunday ) for the custom field B as current date + 2 ( which means if today is Monday then field B value should be Thursday's date)
Can any one help with the post script for the above scenario.
Hi @Srikanth Gogineni ,
This code should do the trick (credits to this post) :
int numberFieldId = 13100
int dateFieldId = 13101
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def numberField = customFieldManager.getCustomFieldObject(numberFieldId)
def dateField = customFieldManager.getCustomFieldObject(dateFieldId)
def numberFieldValue = issue.getCustomFieldValue(numberField)
def dateFieldValue = issue.getCustomFieldValue(dateField)
Calendar c1 = GregorianCalendar.getInstance();
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
dateField.updateValue(null, issue, new ModifiedValue(dateFieldValue, c1.getTime().toTimestamp()), new DefaultIssueChangeHolder())
Of course update custom field ids.
Thank you very much for your code and it is working fine but there is small issue with the script.
Date field is not getting calculated properly when i move to previous/other transitions and changing the "Numberfieldvalue" . it is increment from the existing set date to new date ( not from the current date ).
Current Date : 4/22/2019
Numberfieldvalue : 2
Set Date : 4/24/2019 ( after executing the script)
Now if i go back and change the numberfieldvalue to 1 then the new Set Date is getting updated to 4/25/2019( 2 +1 ) instead of 4/23/2019.
please help on the same.. Thanks
Hi everyone! My name’s Matt and I’m a product manager at Atlassian. I work in the navigation & findability space for all our Jira Cloud products. We’ve been working on trying to improve the exp...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events