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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 set "none" cascade select list to child

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)

Hello @Yury L_ ,

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 L_ likes this
1 vote

"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

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

Learn how to request and manage app requests in the Marketplace

G’day everyone! Super exciting news coming from the Marketplace. We have now fully rolled out the ability for end-users to submit app requests to admins directly from within the product! No longer ...

62 views 1 7
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