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
Thanks. That put me in the right direction. I have implemented this script.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.CustomFieldManager
import org.apache.log4j.Logger
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def issue = issue as MutableIssue
def log = Logger.getLogger("com.acme.workflows")
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def approvalGiven = customFieldManager.getCustomFieldObjectByName("Approval Given")
def approvalGivenVal = issue.getCustomFieldValue(approvalGiven) as ArrayList
def 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 " + optionRelease
approvalGivenVal.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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's great. Thanks for sharing here as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.