hi dear community,
I have write a custom field which get values from an external SQL database and read it in a multi selected custom field.
If I set a value to the custom field all is working fine, but there is a problem if I move the Issue to a another project the value is still exist in the new issue, although it doesn't have values in the other project.
The database query select our available teams for a specific project.
public class FunctionalTeamCF extends GenericTextCFType
{
private static Connection conn;
private static Statement statement;
protected FunctionalTeamCF(CustomFieldValuePersister customFieldValuePersister,
GenericConfigManager genericConfigManager,
TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,
JiraAuthenticationContext jiraAuthenticationContext) {
super(customFieldValuePersister, genericConfigManager, textFieldCharacterLengthValidator, jiraAuthenticationContext);
}
@Override
public Map getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)
{
Map map = new HashMap();
Map<String, String> results = new HashMap<String, String>();
//aktuelles Issue Projekt
String project = issue.getProjectObject().getKey();
results = getValues(project);;
if(!results.isEmpty() && results != null)
{
map.put("results", results);
}
else
{
map.put("results", "None");
}
return map;
}
I suspect that the velocity template file edit.vm makes the problems..
#* @vtlvariable name="results" type="java.util.Map" *#
#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
#if($value && !$value.equals(""))
#set ($displayValue = ${value})
#end
#if($results && !$results.equals("") && !$results.empty)
<select class="text long-field" name="$customField.id" id="$customField.id" >
<option value="">None</option>
#foreach ($mapEntry in $results.entrySet())
<option value="$mapEntry.key">$mapEntry.value</option>
#end
</select>
#else
<select class="text long-field" name="$customField.id" id="$customField.id" >
<option value="">None</option>
</select>
#set ($Value = "")
#end
#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)