I need a way to extract the Salesforce record ID from a URL using Zapier Push. How can I find the first 3 characters in a string that match the start of the Id like 006 and then return a set number of characters after that?
The url is formatted as such:
https://useindio.lightning.force.com/lightning/r/Opportunity/006f400000AiVufAAF/view
David here, from the Zapier Platform team. Good question!
Whenever you want to extract data from a string and you know the exact format the string will be in, Regular Expressions are the answer.
Assuming you want to grab anything after 006
(and you know it'll always be there), you could use the regex 006(\w{15})
(more info), which will find the 15 characters after that. If you know the surrounding url will always be the same, you could easily grab the whole ID by anchoring via Opportunity
and view
: \/Opportunity\/(.*)\/view
(more info).
Either way, there's info about setting up a formatter zap here, or you could do it in code (JS Example, Python Example).
Let me know if you've got any other questions!