OE objects related - save order

Posted by mihai_neagoe on 10-Oct-2014 07:32

Hi,

I have two Rollbase objects created from OE service. On the parent edit page I have a grid control with children. If the parent is changed and also a child then an update is fired for parent Update service and one for child Update.

The order in which is this is done is parent first and children afterwards. Can this be changed? Or this is default behaviour?

As example Order-OrderLine. If I want to update for example the amounts in OrderLine and also approve the Order I would expect to receive first the OrderLine updates and afterwards the Order. Now I receive the Order apprve but with incorrect amounts on OrderLines.

Thank you.

All Replies

Posted by Gian Torralba on 10-Oct-2014 10:54
Hello.

The parent -> child hierarchy when saving a record with a grid control is the Rollbase default functionality. However, you can create a trigger in the parent object that has a type of "after finalize" so that all child processes are finalized before the parent trigger fires.

Hope this helps,
Gian
Posted by mihai_neagoe on 15-Oct-2014 08:28

Hi Gian,

The trigger from the parent is executed indeed when all children are saved but the order is still the same: parent->child. As in the example below: if an Order is approved and the OrderLines have changed quantities in one save -> then we receive the approve Order first (which collects the incorect amounts from lines) and after this the OrderLines. We can add in the 'On finalize' trigger a service invoke to approve the Order when the flag is set but this is too late in our scenario: we need to prevent the first approve on save - it is also an overhead for future deployments : the triggers needs to be changed for each environment.

Could we check a different approach for this?

Thank you

Posted by Gian Torralba on 16-Oct-2014 12:13
Hello,

Are you updating all of this in the order edit page? If so, I believe adding the "on finalize" type in the trigger in the order record will let the order lines finish all updates first before doing the check in the order parent record.

Let me know if this is what you need.

Thank you,
Gian
Posted by mihai_neagoe on 17-Oct-2014 03:13

Hi Gian,

Indeed we update all in the order edit page.

We have tried with two types of trigger: "Update Field Value" and "Object Script". Both triggers had timing set on "On Finalize". For each OpenEdge Business Entity we printed messages on update (OEAppserver log) to test which records were updated first (order or order-lines). In both cases the update for "order" was called before the update for "order-lines".

Is it something we need to change in the setup? Or a different trigger to use?

Thank you,

Mihai

Posted by Gian Torralba on 17-Oct-2014 10:52
Hello,

Can you try putting your trigger on last part of the hierarchy? The purpose of the on finalize trigger is to run the trigger in the last process and running the grid items first. I don't know if this process is the same with OE service objects or there is a bug. I will try testing that also. But if you try testing it via normal rollbase objects, it should work as expected.

Thank you,
Gian
Posted by pvorobie on 17-Oct-2014 11:06

This explains order of execution of triggers:

documentation.progress.com/.../index.html

Posted by mihai_neagoe on 27-Oct-2014 06:28

Thank you, can you please re-attach the link?

Posted by Gian Torralba on 27-Oct-2014 10:28

Hello,

Please try this link. http://documentation.progress.com/output/.../rb/Rollbase.143.html

Thank you,

Gian

Posted by Gian Torralba on 27-Oct-2014 10:33

Sorry about the link. There seems to be a problem attaching the link. You can go to Triggers on page 190 Chapter 5 of the Rollbase User Guide instead.

Thank you,

Gian

This thread is closed