Skip to main content

Hello there,

I need some help to format a text input in a specific way.


I collect information like email address and opt-in for a newsletter subscription from HelloAsso where one or more user can subscribe at once. There is only one input field with all data wether there is 1 or more subscriber(s).

 

The final goal is to send each subsriber’s email address in the newsletter app (Brevo), only if the user opted in (but that’s a step further, first I need to format the text input)

 

Example input for 1 subscriber :
“items_custom_fields_answer” : ”email1@gmail.com,yes”}

 

Example input for 2 subscribers :

“items_custom_fields_answer” : ”email1@gmail.com,yes,email2@gmail.com,yes”}

 

Example input for 3 subscribers :

“items_custom_fields_answer” : ”email1@gmail.com,yes,email2@gmail.com,yes,email3@gmail.com,no”}

 

What I would like to do is split the input value “every second items separated with a comma” in order to get this kind of array output :

i

  {"email1@gmail.com","yes"},

  {"email2@gmail.com","yes"},

  {"email3@gmail.com","no"}

]

 

Do you know if that’s possible with zapier formatting tools ?

Thanks a lot in advance.

Welcome to the Community @ggglyke!

I did some digging and found there’s a feature request open to have custom fields (like the one mentioned here) not output in a nested array like you’re seeing here with the “items_custom_fields_answer” field. I’ve gone ahead and added your vote to that so we can contact you by email the minute that’s been sorted.

In the meantime, it might be better to try using a single Code by Zapier action to split the items up. But it’s a bit more advanced so might not be the best option.

If you wanted to go down the Formatter route you’d need 3 formatter actions. The first two would be Formatter (Text > Replace) actions. The first would replace yes, with yes,>:newline:]. For example:
5741010c47a728d929582b9bc9a320ee.png

And the second would replace replace no, with no,n:newline:] - for the input on the second action you’d select the output from the first formatter action:
ac326a2ae1d33a4b30df936569ea8714.png

That would give you the pairs of values that you want separated by newline characters. Then you’d follow that up with a  Formatter (Text > Split Text) action to find the a:newline:] characters that the previous actions added and select the Segment Index of All (as Line-items) to split them up into an array of line items. For example:

485de813ef75c13e30af86f36d315960.png

Hope that helps. If you run into any issues on that or I’ve misunderstood what you want to have output just let us know! 🙂


@ggglyke 

Some other options to try:

  • Code
    • JavaScript / Python
  • Ask AI
    • ChatGPT - Extract Structured Data

Hi @SamB & @Troy Tessalone thnaks for your answers !

 

I managed to achieve what I wanted to do with a Chat-GPT-generated javascript code snippet because text formatter was giving me a really strange output with the instructions @SamB recommended, it is reapeated 3 times :

 

Input :

“email1@gmail.com,yes,email2@gmail.com,yes,email3@gmail.com,no”

 

Output :

{1:{

“email1@gmail.com”,

“yes”,

“email2@gmail.com”,

“yes”,

“email3@gmail.com”,

“no”,

}

2:{

“email1@gmail.com”,

“yes”,

“email2@gmail.com”,

“yes”,

“email3@gmail.com”,

“no”,

}

3:{

“email1@gmail.com”,

“yes”,

“email2@gmail.com”,

“yes”,

“email3@gmail.com”,

“no”,

}}

 

Tanks all


Hi @ggglyke,

That’s great news! We’re glad to hear you were able to get it sorted!

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