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
Send both CDTs into the process model. Include two Write to Datastore nodes. First write table 1 to the database and used the StoredValues output to save the value back into the process variable for table1. Then use a script task to add the primary key from table one to your foreign key in table 2. Write table 2 to the database.
https://docs.appian.com/suite/help/17.4/Write_to_Data_Store_Entity_Smart_Service.html#node-outputs
I also recommend watching some of our academy videos to better understand writing data from a form to the database
Hi Danny..Thanks for help. I have used a!writeToDataStoreEntity() to save data from form if it was single table.
saveInto:{a!writeToDataStoreEntity(dataStoreEntity: cons!DATA_STORE_ENTITY,valueToStore: ri!rule_input )),
But if you can help with me with the code for saving data from multiple table.
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.
Thanks Stewart... Had used Danny approach