Update user profile after a row is created in other table

Hi,

Viewing the detail of one product, I add a button to create the Purchase form in the background.
So for this I created an action with “Add a row” to Purchase table and automatically complete the fields.
In the same action, how can I change a column in the user profile based in a math column in the just created item Purchase table? Because I have no way to retrieve the last Purchase created.

Thanks for any help!

What are you trying to calculate?

Also, screenshots of tables would be helpful

Hi Tamara,

I will try to put it simple, I hope.

Basically, I am developing a demo of a customer loyalty application for a coffee shop. So, the customer can register into the app and upload the purchases they have made and add points.
Within the application, there is a list of promotions that the customer can exchange for the points of their purchases.
So, when the customer sees a promotion that interests him, he clicks on a button and that should create an item in the redeem table.
Logically, the promotion points must be added to the client’s profile.
In such a way that the profile has a column with the accumulated value of your purchases and another with the accumulated value of your redeems.

The tables:

  1. My Profile

Email | Points Purchases | Points Redeem | Balance (Purchases-Redeem)

  1. Promotions

Name | Image | Points

  1. Purchases

Name | Date | Points | Email

  1. Redeem

Name | Date | Points | Email

As there is no a function to “append” the points of a purchase to the user profile, when I open the Purchases form, in a field I get the default of the current Points Purchases and sum the Points of the new Purchase and the value result updates the column Points Purchases in the profile. That works fine.

But, when I am viewing the Promotions, I cannot add a button to create the form of Redeem, because it is another table.
So, I added a button and set an action that “add a row” to Redeem table.
That works. But I need to update the Points Redeem column in the profile with the current value of this column plus the points of the new redeem (the points of the promotion selected).
That the problem I have.

Thanks for any help!

Emilio

There is a better way to do this. Instead of “hard coding” the “Points Purchases” and “Points Redeem” columns in the User Profile, you can auto-calculate those values.

To do this:

  • Create a multiple relation column in your User Profile table that matches the user email with the email column in the Purchases table.
  • Do the same for the Redeem table.
  • Now create two Rollup columns, one for each relation, that takes a sum of points.
  • Then you can calculate the Balance by subtracting one from the other.
3 Likes

Right! I will try this.
Thank you Darren.