We need to display first value that Date field was set. Steps that I've are:
- From Change History, get 1st Change for this field
- Later using the Formatter object, convert it into a Date object.
- Return the formatted date to display using *Date* Template
{code}
//Find out date when device was deployed 1st time!
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*
import java.text.SimpleDateFormat;
def last_deployed_date_first_change_item = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, "Last Deployed Date").first()
def formatter = new SimpleDateFormat("yyyy-MM-dd")
def first_deployed_date = formatter.parse(last_deployed_date_first_change_item?.to)
formatter.format(first_deployed_date)
{code}
When Date template selected, it throws $dateFormatterWithoutTime.format($value) error. But with Text Field (multi-line) it just works fine.
Since we need Date object that can be used in JQL later, we would like to create a field of type Date.
Let's know what's wrong with the script.