I’m working with Zapier and need to pull out a specific Salesforce record ID from URLs that get sent through my automation workflow. The URLs look something like this:
What I’m trying to do is locate a specific pattern in the URL string - I need to find where certain characters appear (like “001” for accounts) and then grab a fixed number of characters that come right after it. This would give me the complete record identifier that I can use in other parts of my Zapier workflow.
Is there a good way to accomplish this string parsing within Zapier’s built-in tools, or do I need to use some kind of formatter or code step to extract just the ID portion from these Lightning URLs?
honestly, just use zapier’s built-in split text formatter. split by / and grab the part starting with 001 (or whatever your object prefix is). way simpler than regex or custom code - no programming needed. works every time for me.
Code by Zapier is your best option here. Write a simple JavaScript function that splits the URL by forward slashes and finds the Salesforce ID based on position and format. Try const urlParts = inputData.url.split('/'); const recordId = urlParts.find(part => part.length >= 15 && part.match(/^[a-zA-Z0-9]{15,18}$/)); - works great. This beats regex formatters since you can easily add validation logic later, like checking object prefixes or handling weird URL edge cases.
Use Zapier’s Text Formatter with the ‘Extract Pattern’ function - it works great for pulling Salesforce IDs from URLs. The regex ([a-zA-Z0-9]{15,18}) will grab both 15 and 18 character IDs perfectly. Just drop your URL into the formatter step, apply the regex, and you’ll get a clean ID to use in your next steps. I’ve used this method tons of times and it’s super reliable.