Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update field according to SLA field change

sao bien August 6, 2019

Hi All, 

Have you any experiences in updating changes custom field when Indicator (TimeTOSLA field) changed?

I had below code to change value of custom field 2 when Indicator (TTS type) changed but it did not work

Issue issue = event.getIssue()
def changeHolder = new DefaultIssueChangeHolder()

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueService = ComponentAccessor.getIssueService()

def Indicator = "customfield_10815"

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Indicator"}

def customField1 = customFieldManager.getCustomFieldObject("customfield_10815") ---Indicator field
def customField2 = customFieldManager.getCustomFieldObject("customfield_13007")
def customField1Value = customField1.getValue(event.issue).toString()
def customField2Value = customField2.getValue(event.issue).toString()

if (change) {
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.addCustomFieldValue(customField2.idAsLong, customField1Value)
def validationResult = issueService.validateUpdate(event.user, event.issue.id, issueInputParameters)
if (validationResult.isValid()) {
issueService.update(event.user, validationResult)
} else {
log.warn "Did not update issue: $validationResult.errorCollection.errors"
}
}

Br,

Sao

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events