We have a custom field ("followUp") that has one value "Yes". This shows as a toggle button when we want to create an issue. However, when we transition it to a certain state we always want to set this "followUp" to "Yes". So far we have this much code:
CustomFieldManager fieldManager = ComponentAccessor.getCustomFieldManager() CustomField followUpField = fieldManager.getCustomFieldObjectByName("Follow-up") def followUp = issue.getCustomFieldValue(followUpField) //Now how do we set it to the value to "Yes" ?
Thanks for any hints.
I would guess that in this example the "follow up" field is a single checkbox, in which case you want to set it to a Collection<Option>
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.customfields.manager.OptionsManager def optionsManager = ComponentAccessor.getComponent(OptionsManager) def customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("Checkboxes") // Checkboxes is the NAME of my custom field def fieldConfig = cf.getRelevantConfig(issue) def option = optionsManager.getOptions(fieldConfig).getOptionForValue("Yes", null) issue.setCustomFieldValue(cf, [option]) // <1>
This will work if this code runs before the system function to save the issue to the database.
def changeHolder = new DefaultIssueChangeHolder(); followUpField.updateValue(null, issue, new ModifiedValue(followUp, 1 as Integer),changeHolder);
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs