Update Parent after Child is modified

Hi guys,
please how to update PARENT record when CHILD is created/updated/removed?
It looks like easy task but I spent already 2 days on this and I’m going crazy. Tried n community hints, but still no functional solution. Please, can someone help me?

regards Marek

1 12 3,463
12 REPLIES 12

It would be helpful to know what kind of update you are wanting to make to the Parent. If your Child changes are being made in the app from a form, there is a good chance you can update the parent there as well.

Since you have implied that you want the Parent change AFTER the child row is Saved then I’ll continue with that assumption.

I’ll assume you have the “IsPartOf” flag turned on for the Parent/Child relationship.

To make changes to the parent fields when a Child row changes you’ll need to create a Workflow that then calls an Action, call it Action 1.

In Action1 make it of type “execute an Action on a set of rows” and transitions to the Parent row so you can access the parent fields to make updates. The Reference Rows expression is simply [Parent ID].

Create a second Action, Action2, of type “set the values of some columns in this row” and assign it as the Reference Action in Action1.

Update Action2 to select the columns you want to update.

If you are wanting to update with information from the child row that just changed, you will need someway to identify that row so you can implement a SELECT() statement in the parent fields being updated to choose the value from that child.

I hope I have made it clear and it helps.

I almost get it. Only the last part about SELECT I don’t understand. I want the key form the last added child record added to a column in the parent record. If I use the reference column, I get a list of keys of all the child records. How and where do I select the last one, or the one just made by current user.
Hope you can help me out.

Try:

ANY(ORDERBY([Related Childs], [_ROWNUMBER], TRUE))

replacing Related Childs with the name of the column with the “list of keys of all the child records”.

@marcotvic Please check the sample app “EventAction” from www.appsheet com/portfolio/531778. That sample app is updating the parent record when child record is added or updated.

@Aleksi I think I just ran into the issue that maybe @marcotvic was initially referring to. I’ll call it Direct edit of a child record such as when selecting it from a Parent Detail view (not Edit mode).

I implemented your suggested process shown in the EventAction app. But I have realized that while I can now update the Parent based on Direct Edit/Add of a child, The Parent DOES NOT update when Edit/Add a child while in Edit mode of the Parent. My understanding this is because EventsActions on Form Save do not fire for children when changed as part of the Parent Edit.

So…leveraging your experience, is there currently in the UI a way to achieve both Child Edit use cases AND update Parent field with result of child Edit? Use cases are:

  1. Change/Add Child as part of Parent Edit.
  2. Direct Change/Add of Child - not initialed by Parent Edit

I am certain there are Workflow/Action solutions for updates AFTER the UI save, but that is less than ideal!

I am trying to implement the same…
I have two tables - Customer Details (Parent) and Quotation Details (Child).
Parent can have multiple child records and Child ‘IsPartOf’ Parent.

I want to update the customer total cost as I add/update rows in Quotation Details. I have replicated exactly the same event action as @Aleksi mentioned. However, in my app the following scenario gives the desired results (will use the same terms as you have):

  1. Update in Direct Edit - WORKS
  2. Update in Parent Edit mode - WORKS (I have to save the parent for the force update to happen)
  3. Update in Child edit mode - WORKS
  4. Update when child is added - WORKS
  5. Update single row in Child quick edit mode - DOES NOT WORK
  6. Update multiple rows in Child quick edit mode - DOES NOT WORK
  7. Update when row or rows deleted in Child table - DOES NOT WORK

How do I force the event action to update customer total cost from quick edits/delete happening in child table?

First, Quick Edits are different and probably not ideal for a Parent/Child relationship where an update to the other is required - at least at this time. Quick Edits are sent immediately for update in the datasource and you have no way to tap into that action to perform actions of your own.

If you like the idea of Quick Edits and wish to keep them, the only way to make the Parent re-calculate is by using a Workflow. However, as you are likely editing Child records in other ways, this Workflow may get triggered at times when not necessary. I am not sure how you can distinguish between when an Edit is made on the Form versus when it is by a Quick Edit. I suppose you could add a column to track when the edit is made by the form.

For Deletes, I assume you are referring to a Delete when you have accessed the Child row directly - i.e. not through the Parent. In that case, the simplest way is to create a Workflow for Deletes only that forces re-calculation of the Parent. Again, you may see unneeded Workflow triggers when you have deleted “normally” - navigated through Parent to child row to delete.

If for some reason you need to see the Parent update quicker than a Workflow provides, with some effort, you can create a custom grouped delete action to perform the update and then deletion of the child. We can discuss further if needed.

The easiest solution is always an action button that user trigger from parent record. Is that a solution in your case?

Wow Steve, that is a quick response. And a good one. It is working nice, now i can get forward wih some nice actions. Thank you very much.

Bert

Working on a similar situation. As a 3D printing service business, I often have Orders with multiple Parts. Orders (Parent), Parts (Child).

I have a “Parts Printed” field on the Order object that tells me if all parts are “not started” yet, “processing” if some parts are printing and others are not started or completed, and “complete” if all parts are complete. Here is a link to that article:

I was frustrated to learn that I could not trigger a bot based on this field changing, but the update is a result of a formula or workflow I guess (Please correct me if I am wrong).
I wanted to have a bot change the status of the Order (Parent) to reflect that either:
-Order Status → “Processing” when I manually changed one of the Child Parts to (Part Status) “Printing”
-Order Status ->“Needs Pickup” when I manually changed all of the Child Parts to (Part Status) “Complete”

Thus triggering a workflow to notify the customer to schedule a time to pick up there parts.

I followed @Aleksi 's suggestion and tried to copy www.appsheet com/portfolio/531778 Child Updates Parent" example as closed as I could, but no matter which way I try to update the child record, the parent status remains unchanged.

Happy to give access to my app so you can see exactly what I mean. Or if there is a better way to execute this, I am open to suggestions.

(I originally had the two Actions from the linked example as a part of a Bot, but the example doesnt have any workflows or bots, so I deleted mine. It didnt work either way.)

The update in the parent record is a result of the Virtual Column re-calculating upon the next sync. Virtual Column re-calculations are not data change events that can be used to trigger Bots.

To accomplish your goal, you need to set up your Bot’s Event to trigger on the actual data change from the Child record.

Now why didnt I think of that…
Got it to work. Thank you

Doh! Moment for sure.

Top Labels in this Space