Potential issue with applying behavior to a c...

(John Baer) #1

Potential issue with applying behavior to a child item when Parent is saved.

I have a work order app that includes Inventory (products and materials).

I want to automatically update the Inventory items as “allocated” when the items are added to a work order.

Installed Products has been made a child table of Work Orders.

I have created an override form for Installed Products that attaches a custom Save function that is intended to find the Installed Products records that have changed, sum up the values of all related rows and then apply the Sum to the Quantity Allocated column of the Inventory table.

I am finding that the Actions attached to the child form are not executed when I follow the normal flow - Edit parent, add a children record, Save child, Save parent.

The records and values are all saved correctly but the child Actions are not performed.

However, if I VIEW the parent detail and from there Add/Update the child, Save child, the save is applied right away to the child (no parent save) and the child Actions are executed updating the results as I expect.

I have been reading posts about the synchronization between Parent and Children but I am not sure what I am missing here.

Thoughts?

(Tony Fader) #2

@John_Baer1 Even though you press Save on the child record first, the parent record is the first change that is submitted. If you’re looking for a way to know when all of the child rows have been added, too, you can use a workaround like in this demo app: https://www.appsheet.com/samples/Send-an-email-when-children-are-added?appGuidString=75e6fdb0-7d89-4668-a971-0d09d8c15fd1

(John Baer) #3

@tony In this particular case, the problem is that the Child action attached to the child form is not being fired at all.

Shouldn’t it still try to perform the action regardless of order of Parent or Child saving?

I’ve proved this by creating a very simple action to update a Text field.

If I Edit Parent and then Edit child, the action does not fire.

If I Edit only the child, action fires.

(Tony Fader) #4

@John_Baer1 Oh, I must have misunderstood. Thanks for re-explaining.

Could you share a link to your simple app that demonstrates this?

Adding @Adam_Stone_AppSheet

(John Baer) #5

@tony Sorry.

I didn’t see your reply sooner.

I have created a little test app to play with.

The link is:

appsheet.com - Build Powerful Mobile Apps from Spreadsheets

In the app you can add child products to a Parent work item.

When saved, the Serial Number should be automatically updated to “abcd12345”

The appname = ChildActionNotFiring-526414

Test 1

Click a Work item and Edit it.

In the “Items to Install” field click the new button, add a Product and update Quantity but leave Serial Number blank.

Save back to Parent.

Save the Parent.

Viewing the saved Product record, you should expect to see that Serial Number updated.

It is still blank.

Test 2

Click a Work item - DO NOT edit it.

In the view, click New on the “Items to Install” field.

Add a Product and update Quantity but leave Serial Number blank.

Click Save.

The child record is saved right away.

Now view the saved Product record and you will see that the Serial Number IS updated as expected.

Question/Issue:

why isn’t the Serial Number field updated in Test 1? Build Powerful Mobile Apps from Spreadsheets appsheet.com

(John Baer) #6

@tony

Tony, any chance you have looked at this and have a suggestion?

It’s kind of a blocking issue for me as I am not certain of a work around for it.

(Tony Fader) #7

@John_Baer1 It looks like when you add a child row via the nested form (Test 1) it’s not using your custom child form view. This means that your Form Saved action is not being run. In Test 2, you’re not going through that same nested form, so it uses your custom form view. @Adam_Stone_AppSheet

For workarounds… I’m wondering why you can’t just use an initial value for your serial number column?

(John Baer) #8

@tony

Saving serial number was just a test use case to demonstrate the Action was not firing.

I wanted to keep Action complexity out of the issue.

My real use case is to update Inventory counts based on child entries.

In Test 1, entry on the child DOES use my custom form as evident by the side-by-side view.

Maybe when Saving on the Parent, the process doesn’t refer back to this custom child form for any attached Actions/processing?

Regardless, wouldn’t this be considered a bug?

Is there some other way I should be referencing the child form?

For workaround,

I’ll look at triggering similar Actions from the Parent but this can get cumbersome if I am using the same child in numerous places.

And even more so when there are multiple children to contend with.