Hi Experts,

I have created a form consists of 3 fields : username, firstname, lastname.
Upon saving, data from these fields will be saved in database in table 'my_user'.
In the same time, i also would like to save field username in another table called table 'my_user_name'.

I tried creating a section in the form and drag the username field in there.
I also use Store Binder to instruct the field to save in table 'my_user_name'.

Saving field username into table 'my_user_name' works well.
But the problem is, it did not save username along with firstname and lastname together in table 'my_user'.
It only save firstname and lastname in table 'my_user'. I need the field username to be saved in table 'my_user' as well.

How can i achieve that?
Thanks in advance.

  • No labels

4 Comments

  1. How Can you Insert Data in two table?

    Can u please  Explain?

  2. Hi,

    We just added an example in our Knowledge Base related to Store Form Field Data to Multiple Tables. Please have a look.

    Hope it's help.

    Best Regards

  3. thanks Owen.

    I have used you sample and most parts seems to be ok for me.

    storeToOtherFormDataTable(element, newRows, formData, id);I had to chan ge 

    this method to storeToOtherFormDataTable( newRows, id);  as I was getting an error.

    Now I am getting below error.

    -----------------------------------------------

    ERROR 27 Jun 2012 21:09:23 org.hibernate.util.JDBCExceptionReporter  - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=

    ==========> as c6_74_0_ from app_fd_BeanShell formrow_de0_ where formrow_de0_.i' at line 1

    Jun 27, 2012 9:09:23 PM org.joget.apps.form.lib.BeanShellFormBinder executeScript

    WARNING: Error executing script

    Sourced file: inline evaluation of: ``import org.joget.apps.app.service.; import org.joget.apps.app.model.; import o . . . '' : Method Invocation appService.storeFormData : at Line: 54 : in file: inline ev

    aluation of: ``import org.joget.apps.app.service.; import org.joget.apps.app.model.; import o . . . '' : appService .storeFormData ( appDef .getId ( ) , appDef .getVersion ( ) .toString ( ) , formId , rows

     , id )

    Called from method: storeToOtherFormDataTable : at Line: 32 : in file: inline evaluation of: ``import org.joget.apps.app.service.; import org.joget.apps.app.model.; import o . . . '' : storeToOtherFormData

    Table ( newRows , id )

    Called from method: storeData : at Line: 58 : in file: inline evaluation of: ``import org.joget.apps.app.service.; import org.joget.apps.app.model.; import o . . . '' : storeData ( )

    Target exception: org.springframework.dao.InvalidDataAccessResourceUsageException: could not load an entity: [FormRow_demo#admin]; nested exception is org.hibernate.exception.SQLGrammarException: could not l

    oad an entity: [FormRow_demo#admin]

    -------------------------------------------------------------------

    Can you let me know the cause of this error?

  4. Its my understanding that we dont need to create class from your sample.
    My Goal is I want to Store the form data in form table and also external table?
    Question:
    storeToOtherFormDataTable(element, newRows, formData, id);
        StoreUsingJDBC(element, newRows, formData, id);
    AppService appService = (AppService) FormUtil.getApplicationContext().getBean("appService");
    I dont understand the variable you have use 
    element,formData,"appService",can u Elaborate this ?