Does anyone have an example script that can be used in a post function to remove a value from a multi-select custom field?
Hi @Roy Chapman
I think this link might help you https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-remove-values-from-multiselect-checkbox/qaq-p/523033
There are some sample scripts on this page.
Ravi
@Ravi Sagar _Sparxsys_
Thanks. That put me in the right direction. I have implemented this script.
import com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.CustomFieldManagerimport com.atlassian.jira.issue.customfields.manager.OptionsManagerimport com.atlassian.jira.issue.customfields.option.Optionimport com.atlassian.jira.issue.CustomFieldManagerimport org.apache.log4j.Loggerimport com.atlassian.jira.issue.util.DefaultIssueChangeHolderimport com.atlassian.jira.issue.ModifiedValuedef issue = issue as MutableIssuedef log = Logger.getLogger("com.acme.workflows")CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();def approvalGiven = customFieldManager.getCustomFieldObjectByName("Approval Given")def approvalGivenVal = issue.getCustomFieldValue(approvalGiven) as ArrayListdef optionsManager = ComponentAccessor.getOptionsManager()def optionTech = optionsManager.getOptions(approvalGiven.getRelevantConfig(issue)).find {it.value == "Tech"}def optionBusiness = optionsManager.getOptions(approvalGiven.getRelevantConfig(issue)).find {it.value == "Business"}def optionRelease = optionsManager.getOptions(approvalGiven.getRelevantConfig(issue)).find {it.value == "Release"}if (approvalGivenVal?.contains(optionRelease)) {log.warn "Approval Given is set to " + optionReleaseapprovalGivenVal.remove(optionRelease)}def changeHolder = new DefaultIssueChangeHolder()approvalGiven.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(approvalGiven), approvalGivenVal),changeHolder)
(The script is used in 3 places, hence the unused values optionTech and optionBusiness)
Thanks again
That's great. Thanks for sharing here as well.
It looks like you're new here. Sign in or register to get started.