Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

451 views 5 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you