Skip to main content

Hi,

I am currently setting up my new Zap; the key premise of it is: 

Collect customer data in a form > based on the customers specified locations, send form data to business partners in the locations specified.

My current issue is that if a customer selects multiple locations (which is highly likely), Typeform parses the text, and combines the multiple locations into a single string. As a result, the Zap isn’t able to distinguish the individual locations because of the combined string and isn’t distributing the emails to the partners operating in that area.

The only way i can see is to manually create every single relation of potential locations which is an almost impossible ask. 

Some points:

  • Customer data is populated in a typeform. They select their locations as one of the questions
  • Business partner data is already populated in a google sheet
  • The customer may require multiple locations; if so, the customer data needs to be sent in all the places they business partners operate. 

Can anyone help me with a more suitable solution that is scalable?

Many thanks in advance! 

 

(hopefully the description is clear)

 

This is the output of the Typeform data - if you select a single location it is signle text, but if you select multiple, it also has it as single string
​​​​​
these are the business partners. I want the Zap to go through each row in the column and send to all the relevant business partners
If i set up like this, it corresponds to the last row in the image above. But this would take monoths of effort to create every relation.
ideally it would be set up like this, with 1 zap per location

 

Hi ​@jordan_nest 

Use the Looping Zap app to iterate thru each location.

Options: https://zapier.com/apps/looping/integrations#triggers-and-actions

Help: https://zapier.com/apps/looping/help

 


@jordan_nest 

I have a preference for using a code blocks, so to split the string and return line items which you can loop though.  I would do something like the code below. You may need to tweak it to fit what you want to achieve. 

Its looks for N followed by up to 3 digits then splits the line, creating a dictionary that is returned for use in other steps. Like in the lookup value for you spreadsheet.

I hope it’s useful.
 

def parse_and_split_string(input_string):
"""
Splits a string into line items at occurrences of 'N' followed by up to 3 digits (N###).
Returns a dictionary suitable for Zapier, ending with 'output = {}'.
"""
import re

# Regular expression to find occurrences of 'N' followed by up to 3 digits
pattern = r'(N\d{1,3})'

# Split the string using the pattern while preserving the split points
parts = re.split(pattern, input_string)

# Reassemble the line items by combining the text before each 'N###' with the match
line_items = l]
current_item = ""
for part in parts:
if re.match(pattern, part): # If the part matches the pattern
if current_item.strip(): # Add the previous item to line items
line_items.append(current_item.strip())
current_item = part # Start a new item with the current match
else:
current_item += part # Continue appending to the current item

# Add the last item if it exists
if current_item.strip():
line_items.append(current_item.strip())

# Convert the list of line items to a dictionary for Zapier
output = {f"line_item_{i+1}": line_item for i, line_item in enumerate(line_items)}

# Return the final output
return output


# Example usage:

#replace with you input_data variable
input_string = "N1-Item1 detailsN123-item2 descriptionN45 More textN7-Final item details"

# run function
output = parse_and_split_string(input_string)


 


@jordan_nest 

Another option is to use native Zapier Tables as the lookup table.

There is a filter condition for “is one of” that handles arrays of items.

Help links:

 

Zap action: Formatter > Utilities > Text to Line Items

Help: https://zapier.com/apps/formatter/help

 

 


@Badger ​@Troy Tessalone  - thank you both so much for the responses. I really appreciate the help here.

I’m still having several issues;

  1. Unless i’m doing it incorrectly, the looping doesn’t allow for me to do this in a dynamic scalable way
    • I always have to specify which values to look for, meaning, if a customer selects multiple loctions, I have to manually create the relationship between the 2 locations 
    • I have tried using the formatter to break out the string into rows. I can probably get this to walk but it bugs out and adds a comma itself one time, then when i play around with the delimiter, it takes it out. 
  1. If I add in all of the locations in the ‘lookup_value’, this would be the ideal approach. Prior to that, I would need to delimit them so they appear as their own time. But then, I need the Zap to find all the selected locations and only chose them. The problem is, because i’ve specified all the locations, if they’re not selected in the form, the zap doesn’t work.

 

see image; i always have to add the locations. So if these locations arent specified, the Zap struggles

 


@Troy Tessalone  the example of apples and bananas is exactly what i need...but this would be need to be driven by the Zap to say, these locations have been selected, now select is one of based on the response


Hi ​@jordan_nest,

 

To map multiple locations from a form to fields in another application using Zapier, consider creating a multi-step Zap for each location, using the Formatter tool to split text into individual locations, or utilizing a Lookup Table to map responses to specific values. You can also set a fallback value for unmatched responses.

 

Let us know if you have further questions. Thank you.


@jordan_nest 

The I never got on well with Formatter and filter and do think if you use a code block such as below you can add the location question and have it return a list. You can use this list to loop through very easily and add a row for each location in the list. 

Where I have used example data you can remove this and add the Input data from the typeform response. 

It would do away with having to add a new location to the filter/formatter every time they are updated.

Inside the loop you can find and/or update the row with any of the data.  

def parse_and_split_string(input_string):
"""
Splits a string into line items at occurrences of 'N' followed by up to 3 digits (N###).
Returns a list of line items suitable for Zapier, ending with 'output = {}'.
"""
import re

# Regular expression to find occurrences of 'N' followed by up to 3 digits.
# This can be amended to fit the pattern of your data. For example E1 or NW1
pattern = r'(N\d{1,3})'

# Split the string using the pattern while preserving the split points
parts = re.split(pattern, input_string)

# Reassemble the line items by combining the text before each 'N###' with the match
line_items = t]
current_item = ""
for part in parts:
if re.match(pattern, part): # If the part matches the pattern
if current_item.strip(): # Add the previous item to line items
line_items.append(current_item.strip())
current_item = part # Start a new item with the current match
else:
current_item += part # Continue appending to the current item

# Add the last item if it exists
if current_item.strip():
line_items.append(current_item.strip())




# Assign the list to 'output' for Zapier
output = {"line_items": line_items}

return output



# Example usage:
input_string = "Item1 details N123 Item2 description N45 More text N7 Final item details"
output = parse_and_split_string(input_string)


If you don’t code, ChatGPT does a good job with code blocks. Providing you tell it the code is for Zapier and you can use only the standard library and requests. You can also have it explain the code or errors which is useful.

I hope this of  use. 


To all that contributed, thank you so much for the help. I managed to get it working exactly how I wanted it to. all of your suggestions helped get to this point.

Thanks again!

Ps. i’ve stumbled on a new minor issue and have created a new discussion here: 

 

 

 


That’s awesome ​@jordan_nest! A huge thanks to all that helped here!

Additionally, it looks like Troy replied to your new post with a new suggestion.

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 🤗


Reply