import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()def optionsManager = ComponentAccessor.getOptionsManager()def faveFruitOtherFld = customFieldManager.getCustomFieldObjectByName("Add New Vendor Name")def issueService = ComponentAccessor.getIssueService()def faveFruitFld = customFieldManager.getCustomFieldObjectByName("Vendor Name")
def issue = event.issuedef otherFaveFruit = issue.getCustomFieldValue(faveFruitOtherFld) as String
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.comments.CommentManagerimport com.atlassian.jira.user.ApplicationUserimport com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.component.ComponentAccessor
final String groupName = "Procurement"
int numOfVendors = faveFruitFld.size()
for( int i = 0; i < numOfVendors ; i++ )
{ if (faveFruitFld[i] == faveFruitFld){ } else { if (issue.reporter ? ComponentAccessor.groupManager.isUserInGroup(issue.reporter, groupName): true) {
if (otherFaveFruit) {
def fieldConfig = faveFruitFld.getRelevantConfig(issue) def currentOptions = optionsManager.getOptions(fieldConfig) def newSeqId = currentOptions*.sequence.max() - 1 def option = optionsManager.createOption(fieldConfig, null, newSeqId, otherFaveFruit)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.with { addCustomFieldValue(faveFruitFld.idAsLong, option.optionId.toString()) addCustomFieldValue(faveFruitOtherFld.idAsLong, null) } def updateValidationResult = issueService.validateUpdate(currentUser, issue.id, issueInputParameters) if (updateValidationResult.isValid()) { issueService.update(currentUser, updateValidationResult) } else { log.warn("Failed to update issue: ${issue.key}: ${updateValidationResult.errorCollection}") } }
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def wertreporter = issue.reporter.name
def create = wertreporter + " added " + otherFaveFruit +" to the vendor dropdown "
CommentManager commentMgr = ComponentAccessor.getCommentManager()
//Der wirkliche KommentarcommentMgr.create(issue, currentUser, create, true) } }}
the above code is my attempt.
I started with
https://scriptrunner.adaptavist.com/5.6.15/jira/recipes/behaviours/select-list-other.html
how do I "check that the user-provided other value doesn’t actually already exist in the list"?