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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,555,693
Community Members
 
Community Events
184
Community Groups

How to set "none" cascade select list to child

Juan José Marchal Gómez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 14, 2020

Hello,

 

when I use the following code to reset child option in cascade select list is not working.

Could you help me?

Best regards.

 

_________________________

I checked with:

def fieldConfig = customField.getRelevantConfig(issue)

def options = optionsManager.getOptions(fieldConfig)
def parentOption = options.find {it.value == parentValue}
def childOption = "none"

cfModule.setFormValue(parentOption.optionId, childOption )

 

And

def fieldConfig = customField.getRelevantConfig(issue)

def options = optionsManager.getOptions(fieldConfig)
def parentOption = options.find {it.value == parentValue}
def childOption = null

cfModule.setFormValue(parentOption.optionId,childOption )

 

 

2 answers

1 accepted

1 vote
Answer accepted

Hi @Juan José Marchal Gómez 

You can try the code below I usually use for that purpose

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('cfName').first()
def fieldConfig = cf.getRelevantConfig(issue)
def option = ComponentAccessor.optionsManager.getOptions(fieldConfig).find {it.value == parentValue}
def iip = ComponentAccessor.issueService.newIssueInputParameters().with {
addCustomFieldValue(cf.id, option.optionId.toString() )
addCustomFieldValue(cf.id + ':1', null )
}
def uvr = ComponentAccessor.issueService.validateUpdate(user, issue.id, iip)
ComponentAccessor.issueService.update(user, uvr)
Juan José Marchal Gómez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 22, 2020

Hello @Yury Lubanets ,

your code works perfectly.

I spent some time to adapt to my system and check it in "prelive" but this code works perfectly. 

Thanks a lot for your help.

 

My final code is something like:

 

//set version none
log.info("---------- SET VERSION NONE ----------")
def fieldConfig = cfModule.getRelevantConfig(issue)
def option = ComponentAccessor.optionsManager.getOptions(fieldConfig).find {it.value == parentValue.toString()}
log.warn("Parent: " + parentValue)
log.warn("fieldConfig: " + fieldConfig)
def iip = ComponentAccessor.issueService.newIssueInputParameters().with
{
addCustomFieldValue(cfModule.id, option.optionId.toString())
addCustomFieldValue(cfModule.id + ':1', null )
}
def uvr = ComponentAccessor.issueService.validateUpdate(user, issue.id, iip)
log.info("issueServiceUpdate")
ComponentAccessor.issueService.update(user, uvr)
Like Yury Lubanets likes this
1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 14, 2020

"none" is what Jira displays when a select-type field is empty.  It's not actually "none", it's <nothing here>

I have not tried it for myself (as I'm not sure where you might be coding), but try

def childOption = ""

or

def childOption = null

Juan José Marchal Gómez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 14, 2020

Hello @Nic Brough -Adaptavist- ,

in your documentation there are examples "how to set" but I think any about "how to release" :)

I checked also def childOption = "" with no success.

Always appears the same error:

 

IF ""

No signature of method: com.atlassian.jira.issue.fields.ImmutableCustomField.setFormValue() is applicable for argument types: (java.lang.Long, java.lang.String) values: [10233, ] at Script1947.run(Script1947.groovy:48)

 

IF null

No signature of method: com.atlassian.jira.issue.fields.ImmutableCustomField.setFormValue() is applicable for argument types: (java.lang.Long, null) values: [10233, null] at Script1950.run(Script1950.groovy:48)

 

Actually, If I do 

log.warn(parentOption?.childOptions?.toString())

 

the information is:

[20191201, 20191101, 20191001, 20190801, 20190701, 20190601, 20190501 , 20190401, 20190301, 20190101, 20181201, 20181101]

so in my opinion is dificult "to set null or empty because in the map of child there is no this option.

 

Thanks for you quick first answer.

 

Best regards.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events