Want to store value to database from interface which has two tables

I am working on the form which has many section and ultimately many fields so had to create 2 table.

Table 1 has field id, name, address, phone,etc

Id is acting as primary key.

Table 2 is acting as foreign key.

Table 2 has field with marks in maths, geography, physics, chemistry etc.

I am done with the configuration part.

I want to store the value to database once form is submitted. Can anyone help me with it. Thanks.

  Discussion posts and replies are publicly visible

Parents Reply
  • You can use the a!writeToMultipleDataStoreEntities function like the following:

    a!writeToMultipleDataStoreEntities(
                    valuesToStore: {
                      a!entityData(
                        entity: <parent_entity>,
                        data: <parent_data>
                      ),
                      a!entityData(
                        entity: <child_entity>,
                        data: <child_data>
                      )
                    }
                  )

    ...but this won't help you as you need to relate the child entity data to the parent entity data by virtue of the parent's primary key being used as the child's foreign key...unless you can manage the keys yourself? (typically we use the database to auto-generate entity keys). If that is the pattern you're aiming to implement then you'll need to follow Danny's recommendation and do this in a process model as two separate writes to the database.

Children