Stop duplicates from being created in child record table

Well this is long winded because I still have so much to learn. I’ve spent a lot of time going through the documentation and this forum and trying different things but I can’t seem to figure this one out.

I am creating an inspections app. There are 7 categories, each with a set of items to be inspected. When a user creates a new inspection, they will choose which categories (enumlist) they will be inspecting because it changes depending on the equipment. I copied and slightly modified the idea of Fabian’s “Enum2Children” app, using the standard items method to make a grouped action that adds all of the the inspection items to a child table depending on what categories the user selected in the original form. That part works well, but the problem is each time the form is reopened and saved it causes the records to be duplicated. (Obviously if I just use an action button instead of form save it still duplicates if I click it again too.)

Parent Table (inspection report): KEY | REPORT | CATEGORY enumlist | other columns
Child Table (line items): KEY | REPORT ref ispartof parent table | CATEGORY | ITEM | other columns
Standard Items Table read only: KEY | ITEM | CATEGORY enumlist (many categories per item)

The add-new-row to another table action behavior I have for each item: AND(IN(“Category Name”, [Category]), ISNOTBLANK(INDEX(SELECT(Standard_Items[Name] , IN([_THISROW].“Category Name” , [Category])) , 1)))

The grouped action behavior: NOT(IN(INDEX(SELECT(Standard_Items[name] , IN([_THISROW].[report], [category])) , 1) , [Related Line Items][Item]))

So like I said, it adds all the correctly chosen items based on the category when the form saves. But if the user opens and saves the form again it will add all of the same items again with new key values. How do I stop this from happening?
I’m also wondering if there is a way to remove the child table items if the user goes back into the form and unselects the categories (rather than having to visit the table view and delete the items manually). Not a big issue if there isn’t, just a thought.

Thanks for all of your help!

I guess you fire action “on save new form” ?

If I m correct, the action will be keep firing all the time whenever your user update the form.

To avoid this, add new row “ChangeCounter” with inital value 0 as well as data type to changeCounter.

On your action setting, run that actions IF this value is 0.

Meaning, whne the new form is added (or saved) then action will add child. Then user come back to the same row to edit, then save. ChangeCounter increase the number naturally, 1, 2, 3, 4, 5, then I suppose your action condition is ending up with “false”

Otherwise, run those action as it is through the workflow upon adding only. This could be easiest way, but the workflow / action is backend service, your user need to wait for a bit until workflow finished the backend-service and see the new set of child rows inline view for something like 10 secs?

THe first method is action initiated, i.e. the client do the job. So once the form is saved, immdiately your users will see the result, i.e. new set of child row, then will start to sync background.

I assume your are working on Inspection app, where it is quite often app user will use the app where the connectivities are bad or no connection to internet. Use Appsheet off line, then best practice could be avoid to employ workflow, but done all the job by action only as far as possible.


Sorry for the late reply, the changecounter method is working. I did need it to be able to update offline since the users will be in areas where there is no internet connection, so thank you!

1 Like