We implemented a database picker field that almost works the way we need it to, however, during the drop down selection, we are seeing a '- null' in the UI from our field, only when selecting the value.
When the value is selected, the trailing '- null' goes away (that is good) in the actual issue field (view screen).
In the drop down, the value '- null' does not appear.


Only in the field itself during edit, does the '- null' appear.
I have pictures included above for a better illustration.
import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.canned.jira.fields.editable.database.SqlWithParameters
import groovy.sql.GroovyRowResult
// IS_ACTIVE = 1 Active/Enabled
getSearchSql = { String inputValue, Issue issue, originalValue ->
// return SqlWithParameters, that will control the search SQL..., eg:
new SqlWithParameters("""
select INITIATIVE_INTERNAL_ID, INITIATIVE_ID, INITIATIVE_NAME, IS_ACTIVE
from [rpt].[JIRA_INITIATIVE_V]
where lower(INITIATIVE_NAME) like '%' + lower(?) + '%' and
(IS_ACTIVE = 1 or INITIATIVE_INTERNAL_ID = ?)
""", [inputValue, originalValue])
}
getValidationSql = { id, Issue issue, originalValue ->
new SqlWithParameters("""
select INITIATIVE_INTERNAL_ID, INITIATIVE_ID, INITIATIVE_NAME,IS_ACTIVE
from [rpt].[JIRA_INITIATIVE_V]
where INITIATIVE_INTERNAL_ID = ? and
(IS_ACTIVE = 1 or ? = ?)
""", [id, id, originalValue])
}
//renderOptionHtml = { String displayValue, GroovyRowResult row ->
// "${row.INITIATIVE_ID} - ${row.INITIATIVE_NAME}"
//}
renderOptionHtml = { String displayValue, GroovyRowResult row ->
def init_id = row[1].toString()
def init_name = row[2].toString()
"$init_id - $init_name"
}