Custom field updating error (Script runner)

Pumper1 March 27, 2018

Hi all, 

I have a custom field (cuscading select) and when i do update its sometime change value but sometime dont change. I do it with this code:

def muIssue;
def commentManager = ComponentAccessor.getCommentManager();
def issueManager = ComponentAccessor.getIssueManager();
def issue = event.getIssue()
def issueKey = issue.getProjectObject().getOriginalKey()
def catApp = issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("field 1")).toString()
def catApp1 = issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("field2")).toString()
def catSupObject = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("field3")
def issueManager1 = ComponentAccessor.getIssueManager()
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
def issueType = issue.getIssueType().getName()
def issueService = ComponentAccessor.getIssueService()
def linkType = ["link type"]
def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {
def destIssue = link.getDestinationObject()
if (linkType.contains(link.issueLinkType.name)) {
muIssue = issueManager.getIssueObject(destIssue.getId())
log.warn(issue.equals(destIssue))
if(!issue.equals(destIssue)){
OptionsManager optionsManager = (OptionsManager)ComponentManager.getComponentInstanceOfType(OptionsManager.class); Object cValue = catSupObject.getValue(muIssue)
if(issueType.equals("xxx")&&catApp.equals("yyy")){
Map<String,Object>newValues = new HashMap<String, Object>();
Long parrentID = 20893
Long childID = 20895
def parentOptionObj = optionsManager.findByOptionId(parrentID)
def childOptionObj = optionsManager.findByOptionId(childID)
newValues.put(null, parentOptionObj)
newValues.put("1", childOptionObj)
catSupObject.updateValue(null, muIssue, new ModifiedValue(cValue, newValues), new DefaultIssueChangeHolder());
}  
}

}
}
issueIndexingService.reIndex(issueManager.getIssueObject(muIssue.id));

Maybe somebody know how to fix it? 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events