You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello!
I try to add a new custom field to Jira Issues. And I’ve faced few problems.
$webResourceManager.requireResource("com.atlassian.auiplugin:aui-select2")
<script type="text/javascript">
AJS.toInit(function () {
AJS.$("#$customField.id").auiSelect2();
});
</script>
My edit velocity file code:
#disable_html_escaping()
#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
<form class="aui" style="width: available">
<script type="text/javascript">
AJS.toInit(function () {
AJS.$("#$customField.id").auiSelect2();
});
</script>
<select class="js-example-placeholder-single js-states form-control" name="$customField.id" id="$customField.id" style="width: inherit">
<option></option>
#foreach ($option in $options)
<option value="$option">$option</option>
#end
</select>
</form>
#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)
My atlassian-plugin.xml web-resource dependencies:
<web-resource key="aui-fields-resources" name="aui-fields Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<dependency>com.atlassian.auiplugin:jquery</dependency>
<dependency>com.atlassian.auiplugin:jquery-ui-other</dependency>
<dependency>com.atlassian.auiplugin:aui-select2</dependency>
<context>atl.general</context>
<context>atl.admin</context>
<resource type="download" name="aui-fields.css" location="/css/aui-fields.css"/>
<resource type="download" name="aui-fields-js.js" location="/js/aui-fields-js.js"/>
<resource type="download" name="images/" location="/images"/>
<context>aui-fields</context>
</web-resource>
Jira v.8.19.1 (Server), Atlassian SDK v.8.2.7
Hi Alex.
I'm trying to use this solution but my field does not pick any options.
could you share the final versions of your js and vm files?
the solution was to use for multiselectCF
#foreach( $option in $configs.options )
instead of
#foreach ($option in $options)
btw i've added some check for disabled options/ complete template looks like
#disable_html_escaping()
#customControlHeader ($action $customField.id $customField.name
$fieldLayoutItem.required $displayParameters $auiparams)
<script type="text/javascript">
AJS.toInit(function () {
AJS.$("#$customField.id").auiSelect2();
});
</script>
<select class="js-example-placeholder-single js-states form-control" id="$customField.id"
multiple="multiple" name="$customField.id">
<option></option>
#foreach( $option in $configs.options ) )
#if (!$option.disabled || $option.disabled == false) ||
($value && $value.contains($option.optionId.toString())))
<option value="$option.optionId"
#if ($value && $value.contains($option.optionId.toString()))
selected="selected"
#end
>$cfValueEncoder.encodeForHtml($option.value)</option>
#end
#end
</select>
#customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)