Hi,
I want to write a script post function on sub-task transition to "Done" in order to delete values in a custom field of type multiselect checkbox on its parent.
Can you please advise how to remove values from multiselect checkbox custom field?
Thanks!!
Community moderators have prevented the ability to post new answers.
Hello,
This should help you set the checkbox field to the new values:
https://answers.atlassian.com/questions/64039
https://answers.atlassian.com/questions/24642640
You can provide a list of options when you call issue.setCustomFieldValue()
Hi Alina,
do you mean that i need to set a list of existing values but the one i want to remove?
What kind of list do i need to create? list of option id's?
Is there a way to remove a single value from being checked?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Paz
You can get the list of currently checked values with:
issue.getCustomFiedValue(checkBoxField).
This gives you a list of Option objects.
https://docs.atlassian.com/jira/7.0.7/com/atlassian/jira/issue/customfields/option/Option.html
You can iterate through this list, check the value using the getValue() method and remove the option from the list if you don't want to keep it.
Then you can set the custom field value to the new list.
Check the examples I gave you and I think it will be clearer. They were useful to me for a similar task.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alina,
Thanks much!
I think my script got better but it still doesn't work and there are no errors, can you please advise?
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.fields.config.FieldConfig import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.customfields.manager.OptionsManager import com.atlassian.jira.issue.customfields.option.Option MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("PP-10") CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager(); def involvedField = customFieldManager.getCustomFieldObjectByName('Involved teams') def involvedValue = issue.getCustomFieldValue(involvedField) ArrayList<Option> myList =(ArrayList<Option>) involvedValue ArrayList<Option> values = new ArrayList<Option>(); for(Option option : myList){ if(option.getValue() != "B"){ values.add(option) } } issue.setCustomFieldValue(involvedField,values)
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.
Hi,Paz
Sorry I couldn't get back to you, I was out of office for a few days with limited Internet access.
Great to hear you got it working! You are very welcome
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.