Hi There! I'm brand new to Groovy Scripts but very familiar with Jira Server.
I'm using Jira Server v7.10.1. I am trying to implement a script post-function using ScriptRunner which will update my custom field for Time Stamp In Progress with the date and time that the transition from Create to In Progress occurs.
I've been scouring the Atlassian Community posts, and am currently testing out the script below. We are using Jira Business, not Software, so we do not have Component Manager declared. This may not be a concern, but wanted to call it out!
The field I want to populate with the current date and time is Time Stamp In Progress (field ID 16882).
Any guidance would be very appreciated
Thank you!
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import static java.lang.Math.*
import java.sql.Timestamp
// get current issue
Issue issue = issue
customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
// Getting custom field value
cfFuncDate = issue.getCustomFieldValue( customFieldManager.getCustomFieldObjectByName("Time Stamp In Progress") )
// Getting custom field object
cfoFuncDate = customFieldManager.getCustomFieldObjectByName("Time Stamp In Progress")
// get today's date
today = new java.sql.Timestamp(new Date().getTime())
// set value
if (!cfFuncDate)
issue.setCustomFieldValue(cfoFuncDate, today)