Need Help with Updating Fields in After Creating a Custom Order

I’m currently working on a management application for car dealerships and I’m facing some challenges with updating certain fields in my database after a custom order is created.

Here’s what I’m trying to achieve:

After a custom order is created, I want to update the ‘Average Order Price’, ‘Order Count’, and ‘Points’ fields in the ‘Dealership’ data type. The ‘Points’ should be calculated based on a simple formula that takes into account the ‘Average Order Price’ and ‘Order Count’.

I want to display a ranking of each car dealership based on these fields.

Here’s where I’m at:

I’ve managed to create the custom order, but I’m having trouble figuring out how to update the ‘Average Order Price’ and ‘Order Count’ fields in the ‘Dealership’ data type.

Here’s what my database structure looks like:


I would really appreciate it if someone could guide me on how to set up the workflows and/or database structure to achieve this. Any help or pointers would be greatly appreciated!

Thank you in advance!