Javascript In Zapier: Split by "-" to multiple outputs

696 views Asked by At

I'm trying to take text in a string like this:

"- Data 1 - Data 2 - Data 3"

And split each of those using javascript into their own "output" for zapier. The goal is to be able to take that data and each data line is used to pre fill a form for a customer like this:

theinternet.com/exampleform/?input1=Data%201&input2=Data%202&input3=Data%203

I either need to be able to use javascript to create the url or have multiple outputs that I can use to integrate with another zap.

There could be as many as 20 data lines or as few as 1 so it needs to be scaleable?

Maybe there is a better way to do it other than javascript?

Does anybody have any ideas?

1

There are 1 answers

0
Micah Austin On

Problem solved this with a buddy from work. I'm not sure I understand enough to explain it. But this did what we needed to.

var string = inputData.data
var obj = {}

string
    .split("- ")
    .forEach(function(item, i) {
        obj[i] = item
    })

output = [obj]