Does anyone know how via groovy I can update in bulk a ton if ticket without it affecting the Last Updated date field. I have the below code that DOES update the last updated date.
Can you please help me figure this out.
Thank you!
_____________
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.*;
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.user.ApplicationUser
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def issueManager = ComponentAccessor.getIssueManager()
def ProjectKeytoUpdate = "TPA"
for (int key = 22104; key <=22104; key++) {
Issue issueObject = issueManager.getIssueObject(ProjectKeytoUpdate + "-" + key)
if(issueObject && issueObject.key.take(ProjectKeytoUpdate.length()) == ProjectKeytoUpdate){
CustomField RequesterField = customFieldManager.getCustomFieldObjects(issueObject).find {it.name == "Requester"}
ApplicationUser RequesterUser = issueObject.getCustomFieldValue(RequesterField) as ApplicationUser
if(RequesterField){
ApplicationUser ReporterUser = issueObject.reporter as ApplicationUser
if (ReporterUser != RequesterUser){
try{
issueObject.setReporter(RequesterUser)
issueManager.updateIssue(RequesterUser, issueObject, EventDispatchOption.DO_NOT_DISPATCH, false)
def changeHolder = new DefaultIssueChangeHolder()
ComponentAccessor.getComponent(IssueIndexingService).reIndex(issueObject)
log.warn issueObject.key + " | Copyed field " + RequesterField.name + " to Reporter with value of " + RequesterUser + " (Orignal Reporter Value: " + ReporterUser + ")"
}catch (all){
log.warn issueObject.key + " | Failed to copy field " + RequesterField.name + " to Reporter with value of " + RequesterUser
}
} else {
log.warn issueObject.key + " | Fields have the same values. Requester: " + RequesterUser + " to Reporter with value of " + RequesterUser + " (Orignal Reporter Value: " + ReporterUser + ")"
}
}
}
}
It is my understanding that I should be using the below code to do so but this is to update a custom field and not a system field.
// custom field reference
CustomField myCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(MY_CUSTOM_FIELD_ID);
// construct the new value
ModifiedValue newValue = new ModifiedValue(issue.getCustomFieldValue(myCustomField), "new value");
// update the field to "new value"
myCustomField.updateValue(null, issue, newValue, new DefaultIssueChangeHolder());