Hello Atlassian Community, I'm asking you today because I'm stuck on the script of a scripted field (I'm using ScriptRunner).
Here is my usecase :
A "Start date" (Date Picker) field is diplayed on my ticket and I have created a "Week Number" scripted field, also displayed on this ticket.
I would like to retrieve format "W25 2022" on Week Number field based on the Start date.
I have started some script on the Week Number field :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import static java.util.Calendar.WEEK_OF_YEAR
import static java.util.Calendar.YEAR
import java.sql.Timestamp
Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// get Start date custom field
def date1 = customFieldManager.getCustomFieldObjectByName("Start date")
// get Start date value
def date1Value = issue.getCustomFieldValue(date1) as Date
// create Week Number custom field
def date2 = Calendar.getInstance()
// copy in Week Number the Start date value
date2.setTime(date1Value)
// transform date2 into format "WeekWW YYYY"
return (issue.getCustomFieldValue(date2) as Timestamp)?.toCalendar().get("WEEK_OF_YEAR", "YEAR")
If anyone has any idea on this topic, it will be appreciated 