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 )
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 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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.