I have two tables with a one to many relationship, an owners table and a pets table which are connected via the Owner ID. The owner can have many pets. I am trying to add an action under the owner summary view for the user to be able to add a new pet that belongs to the owner but I am struggling with how to connect the two records. I have created a related action under owner that points to the add / update pet but I am struggling to connect the owner ID to the pet being added, any help would be greatly appreciated!
Discussion posts and replies are publicly visible
Pass in the Owner ID to your Record Action Start Form. Then you can use it to populate the ownerId attribute of the pets you want to create.
desmondw Since you already have a summary view of the Owner, which means you have the Owner ID, and a one-to-many relationship is created based on the Owner ID, you have the Owner ID field present in the Pets record. So, simply create an Add/Update action for the Pets record with the Owner ID as a foreign key.
So the form I am trying to use is a wizard with milestones, and the owner information is created on the first step, then the pets are added in to an editable grid on the second step. Will this cause any issues, or is there another way to do it since the owner is being created roughly at the same time as the pets?
desmondw Your approach is correct if you're using a milestone.I assume you've already completed this step: The Owner to Pets relationship is one-to-many, with ownerId as the common field. If you're currently on the milestone of adding owner details, you can directly use the owner record fields to save data. When you proceed to add pet details, use the owner.relationship.pets.fields to add pet details. Once you've saved both owner and pet details in the owner record, simply use the write record function or a smart service to write to the database. Appian will automatically add the ownerId to the pets table to create the relationship; you don't need to manually input it.
This is the route I ended up going down in my troubleshooting, thank you!