I have written a listener to fire on the "issue updated" event which will populate a date/time custom field with the current time stamp, IF the issue has a specific label.
The script updates the customField as intended when the issue is updated, however I only want this timestamp to be entered when the label is initially added; I don't want the field to EVER update after that. How can I have this listener not update the field if it is already populated?
I have added my current script below...
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import java.sql.Timestamp
Issue issue = issue
def issueLabels = issue.getLabels();
boolean containsLabel = false;
for (String label : issueLabels) {
if (label.contains("examplelabel")) {
containsLabel = true;
}
}
if (containsLabel == true) {
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("myCustomField")
def changeHolder = new DefaultIssueChangeHolder()
def now = new Timestamp(new Date().getTime())
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), now),changeHolder)
}