Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,974
Community Members
 
Community Events
168
Community Groups

How to purge child level of cascading field with script ?

Edited

please help me to correct my script. I added a publish function, to the transition create. In order to purge the child level of a cascading field.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.issue.IssueImpl

def changeHolder = new DefaultIssueChangeHolder()
 

switch(issue.issueType.name) {
case "Evolution":
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11505)
break
case "Incident":
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11503)
break
case "Demande d'informations":
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11504)
break
case "Changement":
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11506)
break
case "Documentation":
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11507)
break
case "Récurrent":
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11508)
break
}


def fieldConfig = customField.getRelevantConfig(issue)
def cFieldValue = issue.getCustomFieldValue(customField)

def parentOpt = ((Map<String, String>) issue.getCustomFieldValue(customField)).get(null)
def childOpt = ((Map<String, String>) issue.getCustomFieldValue(customField)).get("1")
def newValue = [:]

newValue.put(null, parentOpt)
newValue.put("1", null)
customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), newValue),changeHolder)

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS

Atlassian Community Events