We have implemented two custom fields for Jira in our App, that provide information displayed as a select list in html.
When these custom fields are present in the Create Issue dialog and the value of them is untouched, the creation of the issue is triggered 3 - 5 times.
In the developer console, we can see clearly that the QuickCreateIssue.jspa is indeed called multiple times:
Although you can also see in the Analytics log, that the first call has the "added" value in the quick.create.fields object, and the following logs have "same" as values.
In Jira Version 8.18.1, this also results in an error message after the first issue is created, in the dialog:
XSRF Security Token Missing
Jira could not complete this action due to a missing form token.
You may have cleared your browser cookies, which could have resulted in the expiry of your current form token. A new form token has been reissued.
Request URL: /jira/secure/QuickCreateIssue.jspa
The original input has been captured and you can retry the operation.
Luckily this error prevents the multiple creation of the issues, but on our other System (Jira version 8.20.1), this error doesnt occur and multiple issues are created.
We have no idea why this happens, since the custom fields don't do anything fancy, we followed closely the official tutorial to create them.
Our custom field CreateTransportField java class:
@Scanned
public class CreateTransportField extends GenericTextCFType {
@ComponentImport
private CustomFieldValuePersister customFieldPersister;
@ComponentImport
private GenericConfigManager genConfigManager;
@ComponentImport
private TextFieldCharacterLengthValidator textFieldCharacterLengthValidator;
@ComponentImport
private JiraAuthenticationContext jiraAuthenticationContext;
@Autowired
protected CreateTransportField(CustomFieldValuePersister customFieldValuePersister,
GenericConfigManager genericConfigManager,
TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,
JiraAuthenticationContext jiraAuthenticationContext) {
super(customFieldValuePersister, genericConfigManager, textFieldCharacterLengthValidator,
jiraAuthenticationContext);
this.customFieldPersister = customFieldValuePersister;
this.genConfigManager = genericConfigManager;
this.textFieldCharacterLengthValidator = textFieldCharacterLengthValidator;
this.jiraAuthenticationContext = jiraAuthenticationContext;
}
@Override
public Map<String, Object> getVelocityParameters(
final Issue issue,
final CustomField field,
final FieldLayoutItem fieldLayoutItem) {
final Map<String, Object> velocityParams = super.getVelocityParameters(issue, field, fieldLayoutItem);
if (issue == null) {
return velocityParams;
} else if(field != null) {
// add options to velocity map
List<KeyValue> transportTypeOptions = getOptions();
velocityParams.put("transportTypeOptions", transportTypeOptions);
// add current option to be displayed
Object value = field.getValue(issue);
if(value != null) {
String displayValue = "";
for(KeyValue option : transportTypeOptions) {
if(option.getKey().equals(value)) {
displayValue = option.getValue();
}
}
velocityParams.put("displayValue", displayValue);
}
}
return velocityParams;
}
private List<KeyValue> getOptions() {
List<KeyValue> result = new ArrayList<>();
result.add(new KeyValue("-", "- - -"));
result.addAll(TransportType.getAll()); // This static method just returns a list of KeyValue entries.
return result;
}
}
Custom Fields view.vm:
$!displayValue
Custom Fields edit.vm:
#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
$webResourceManager.requireResourcesForContext("atl.general")
<select id="our-custom-field" name="$customField.id" class="medium-long-field"
data-aui-validation-field style="vertical-align: top;">
#foreach( $transportType in $transportTypeOptions )
#if($transportType.key == $value)
<option value="$transportType.getKey()" selected>$transportType.getValue()</option>
#else
<option value="$transportType.getKey()">$transportType.getValue()</option>
#end
#end
</select>
<script type="text/javascript">
AJS.$(function() {
AJS.$("#our-custom-field").auiSelect2();
});
</script>
#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)
Create Issue Postfunction:
We just use the default, no extras:
Any hints are greatly appreciated.
Jira Version: 8.18.1 and also 8.20.1
Hi @Arthur , can you also show us the implementation? It's hard to help without knowing how exactly you implemented it (Script, workflow post functions, automation etc.)
Best, Max
I updated the post as you requestetd. Thanks for the fast response.
Kind regards
Arthur
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.