It is also possible to query through jdbc from the properties of a specific section of a form (Edit Section > Data Binder > Configure Bean Shell Form Binder), and if you are sure that the query returns a single value, take it directly to a form element (a hidden field or text box), with something like (sql is a string with the query):
ApplicationContext ac = AppUtil.getApplicationContext();
DataSource ds = (DataSource) ac.getBean("setupDataSource");
conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(sql);
String query_result_variable = "";
if (rset.next())
{
query_result_variable = rset.getString(1);
}
and after this process, write the result to the form element:
FormRow r = new FormRow();
r.put("form_field", query_result_variable);
f.add(r);