I need to prevent users from selecting more than one component when creating new tickets, so I'll be able to work with auto-assignement by component according component selection.
Currently JIRA allows multi-selection for components and assigns the ticket to component lead of the last component selected on the ticket creation.
I already tested the JIRA Misc Workflow Extensions plugin and it works, however we've already purchased the Scriptrunner plugin.
I know it's possible to add a Behavior using Scriptrunner, however all examples I found here at answers are not working.
I'm working with JIRA 7.x and Scriptrunner 4.3.16.
Thanks,
Take a backup of components-edit.vm and then add the following
#disable_html_escaping()
#customControlHeader ($action $field.id $i18n.getText($field.nameKey) $fieldLayoutItem.required $displayParameters $auiparams)
#if ($components && !$components.empty)
#if (!$fieldLayoutItem.required)
#set ( $componentHeaderSize = 1)
#end
<select class="select" id="$field.id" name="$field.id"
size="#minSelectSize($components $componentHeaderSize 5)"
data-remove-null-options="true" data-submit-input-val="true" data-input-text="#if (!$bulkEdit)$textutils.htmlEncode($!frotherInputText)#end" data-create-permission="$!{createPermission}">
#if (!$fieldLayoutItem.required)
<option#if ($currentComponents && $unknownComponentId && $currentComponents.contains($unknownComponentId)) selected="selected"#end value="-1">
$i18n.getText('common.words.unknown')
</option>
#end
#foreach ($component in $components)
<option#if ($currentComponents && $component && $currentComponents.contains($component.id)) selected="selected"#end title="$textutils.htmlEncode($component.name) #if($component.description) - $textutils.htmlEncode($component.description)#end" value="$!component.id">
$textutils.htmlEncode($component.name)
</option>
#end
</select>
#if ($!isFrotherControl)<div class="description">${i18n.getText('generic.picker.static.desc')}</div>#end
#else
<span class="field-value">$i18n.getText('common.words.none')</span>
#end
#customControlFooter ($action $field.id $fieldLayoutItem.getFieldDescription() $displayParameters $auiparams)
And restart your server and check.
In the create transition, you can put a custom script in the "validation" phase of the transition. Script runner provides ability to write "Custom script validator" in the validation phase and in the validation phase you can check how man components the issue has, and if it has more than 1 component you can return false.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
#disable_html_escaping() #customControlHeader ($action $field.id $i18n.getText($field.nameKey) $fieldLayoutItem.required $displayParameters $auiparams) #if ($components && !$components.empty) #if (!$fieldLayoutItem.required) #set ( $componentHeaderSize = 1) #end <select class="select" id="$field.id" name="$field.id" size="#minSelectSize($components $componentHeaderSize 5)" data-remove-null-options="true" data-submit-input-val="true" data-input-text="#if (!$bulkEdit)$textutils.htmlEncode($!frotherInputText)#end" data-create-permission="$!{createPermission}"> #if (!$fieldLayoutItem.required) <option#if ($currentComponents && $unknownComponentId && $currentComponents.contains($unknownComponentId)) selected="selected"#end value="-1"> $i18n.getText('common.words.unknown') </option> #end #foreach ($component in $components) <option#if ($currentComponents && $component && $currentComponents.contains($component.id)) selected="selected"#end title="$textutils.htmlEncode($component.name) #if($component.description) - $textutils.htmlEncode($component.description)#end" value="$!component.id"> $textutils.htmlEncode($component.name) </option> #end </select> #if ($!isFrotherControl)<div class="description">${i18n.getText('generic.picker.static.desc')}</div>#end #else <span class="field-value">$i18n.getText('common.words.none')</span> #end #customControlFooter ($action $field.id $fieldLayoutItem.getFieldDescription() $displayParameters $auiparams)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.