dcolley / integromat-facebook-support

0 stars 0 forks source link

[QUESTION: Adding new relation to Airtable] Hi everyone! I'm sending purcha... #136

Open dcolley opened 3 years ago

dcolley commented 3 years ago

Source: copied from https://www.facebook.com/groups/integromat/permalink/3968662866577650/

[QUESTION: Adding new relation to Airtable] Hi everyone! I'm sending purchase orders and clients' information from Woocommerce to Airtable.

So there's a table called ORDERS and a table called CLIENTS that are related. A CLIENT should have all ORDERS purchased in the relation field. Whenever an order is made, it sums 1 row to ORDERS and checks if that client is already registered.

  1. If not, it creates it with that ORDER's relation.
  2. If it exists, i want Integromat to add that new ORDER to the ORDERS RELATION field. But, what it does is replacing previous orders with the new one. Below there are several images that show the case.

Can you give me a hint? Thanks in advance for your kind help!

dcolley commented 3 years ago

Comment ID: 3968829363227667 This is where I am confused.

Why are you doing the "get client orders". From what I understand, you can only have one client, but each client can have many orders?

So in Airtable when you link the clients and orders, you need to make sure that clients can have multiple orders, but not the other way around

dcolley commented 3 years ago

Comment ID: 3968832109894059 Orders

dcolley commented 3 years ago

Comment ID: 3968846656559271 So I am guessing your airtable looks something like this.

So when an order is created in woocommerce, depending on how much validation you feel like doing.

  1. Watch woocommerce for new orders.
  2. Search the airtable client table to see if the client exists (check on an ID if you have it or email).
  3. You can then upsert the record (update if exists, create if it doesn't).
  4. Create the order record - again, do you need to check if the order already exists and then upsert? When you create the order, link it with the client record.

Is that right?

dcolley commented 3 years ago

Comment ID: 3970778203032783 Hey Scott Deewizz! Thanks for your reply! Yes, Allowing linking to multiple records is enabled and working.

The relation should be:

The workflow i built goes pretty much like you said (to simplify, i will only describe the case when the client already exists in Airtable):

  1. It creates the order
  2. Checks by email whether that client exists or not
  3. I tried Upserting directly, but whenever you insert information in a field, any data in that field gets replaced... which makes sense, but there should be a way to: 1) retrieve previous data 2) add new data 3) Insert all it into that relation field That's why my 3rd step is Getting that client's orders. (it might not be needed)
  4. Here, i'm telling airtable module to upset information about the client and upsert Step 3's retrieved orders. The result is, if there are 5 Orders, that last module gets executed 3 times: Everytime it upserts the (i) order retrieved, so as result, i get only the last Order inserted.

I've updated the first image to make it clearer.

Any clue on how to tell an airtable module to insert an array of 5 items into a relation field?

Thanks again Scott!

dcolley commented 3 years ago

Comment ID: 3971949459582324 Javi BG can you screenshot? I dont know what you mean by relationship order.

What is your unique variable to identify a client?

Are you doing this when orders are created and modified,?