Is it possible to update multiple records from information in one email?
I know I can use the “When email received” trigger to create a record and extract the body of the email into that record. However, I sometimes receive emails with information that belongs to different records in Airtable.
Initially, I receive an order confirmation. That contains only information about one order, so I can set Airtable up to create a record from each order confirmation.
When the order is ready, I receive another email, and that email often contains information about multiple orders.
The data in the body of the second email is structured roughly like this:
The ordered materials have arrived.
Order number: … [Other details about the materials]
Order number: … [Other details about the materials]
Order number: … [Other details about the materials]
You cannot respond to this e-mail…
The order number is in the initial order confirmation, too.
Is it possible to update the status field of each of the relevant records (orders) that I created from the order confirmations?
Feel free to ask if my explanation doesn’t make sense. English is not my first language. Thanks, Lene
Page 1 / 1
Hm yeah, you could try putting the full text of the email into a long text field, then using formula fields to extract the order details either with the REGEX formulas or lots of SUBSTITUTES. This works but would be pretty clunky, you’d need to have one field per order in the second email, which is fine if there are like 5 maximum or something, but if it goes to dozens this is pretty tedious
You’d also then need to create an automation that would run per field here too
---
If you’re comfortable with scripting (or using ChatGPT) then that works too, you’d get the script to extract the data and output it into an array, then use a Repeating Group on the array to find and update one record per Order Number
I’d recommend doing the script option if possible; it’s cleaner and easier to maintain overall I think
Can you provide an example of the second email’s text?
You could feed the body of the email to the AI action, and ask it to output a list of order numbers. Then you could use a repeating group to go through each order number on such list. Then you could have a Find Records action within the repeating group, to find the corresponding record based on the order number. For last you could have an Update record action after the Find Records, and within the repeating group, to update the corresponding record.
If you need any help setting this up, please feel free to grab a slot using this link. I’d be happy to show you around!
console.log(`Updated order ${data["Bestillingsnummer"]}`);
} else {
console.log(`No matching "Ordered" record for Bestillingsnummer ${data["Bestillingsnummer"]}`);
}
}
}
Hard to say without an example of your full email text I’m afraid. When you tried it out did it work right?
Hi, Parsing require precision in details, so you can test and see if script works. I just made a small test with a different approach - I did Find records for Ordered status and then used results to avoid querying in script. You can use it in case of any problems with ChatGPT version
From Find Records, order numbers added as ‘numbers’ and record IDs added as ‘ids’ at the left side of editor. Email text added as ‘mail’
I just typed random nonsense for test
Looks good
Of course if your email text has differences it might not work for you. Or you should make minor fix in the script.
Ouch, i forget about updating Status field it just require updating one line in script above. I suppose your Status is Single-select field, and if yes, GPT script won’t work
I have decided not to do this anyways. What is the best thing to do with the thread? Should I delete it or somehow close it?
Just mark any answer as ‘best’ so this topic will disappear from ‘Unanswered’, but will be available for searching for somebody with the same question. My script created for exact sequence of dividers (empty lines, colon), so it must be edited to work for different mails. Thus, maybe @Mike_AutomaticN reply is more useful here. And if somebody want to create own script, they can scroll and use any of quoted here as template.