1
0
-1

Hi All,

I have a select box with Options Binder as 'Beanshell Form Binder'.

I am loading the options using Beanshell script from a database table which is working fine.

However I need to filter the database values based on a form text field (value= ABC) and I tried using below code:

String str = "#form.formtablename.fieldname#";

LogUtil.info("","("+str+") - my text field value");  

Current Result : String is getting printed as :

(#form.formtablename.fieldname#) - my text field

Expected Result: String should be printed as below:

ABC - my text field

Can you please let me know why the text value is not getting displayed.

 

  1. Priyanka

    Thanks Andrew, we tried this solution and also set "Field ID to control available options based on Grouping" to our textfield.

    Our SQL query is :

    PreparedStatement  stmt = con.prepareStatement("Select Claim_num from Claims where Claim_num = ?");

    However now when we run the code we get a JDBC error for PreparedStatement on the line:

     stmt.executeQuery() since it does not get the corresponding value to substitute for '?'

    Please suggest how to get the textfield (Field ID to control) value  in Beanshell

    NOTE: We also tried below option but it tries to search claim numbers with '?' and gives zero result as no claims with ? as present in database table.

    PreparedStatement  stmt = con.prepareStatement("Select Claim_num from Claims where Claim_num = '?'  ");

     

  2. Priyanka

    Thanks Hugo, the above solution worked :) We get the textfield data in "values" variable and then use it from there as required.

CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    Hi

    You can key in your form field used for select box filtering into the select box properties "Field ID to control available options based on Grouping".

    Subsequently, in your SQL query where clause, add a question mark and Joget Workflow will replace the value of the filter field into the '?' query place holder. Remember to tick 'on' the "Use AJAX for cascade options?" checkbox.

     

    Example:

    Select * from dir_user where active=?

     

    The form hash variable #form.formtablename.fieldname# is a Joget shortcut to PULL values from the database table on form load. It will work if the database table "formtablename" for record "id=123" already has a value in "c_fieldname" and id=123 is the record currently being displayed in your form. But if "id=123" is a new record (don't exist in database), the hash variable will not work.

     

      CommentAdd your comment...