Skip to main content

Hello, I am using the “Configurable list” widget in Jotform and list items are coming across to my Zap in a single field like so:

/{"CaptorName":"room 1","UseCase":"Control 1"},{"CaptorName":"room 2","UseCase":"Control 2"}] 

 

However, I need to reformat them to fit into this format and create 2 different rows in Airtable:

 

 

Can you help me make this happen, please?

Hi @DPA 

Good question.

Airtable supports creating records with line items.

 

Or try using the Looping app: https://zapier.com/apps/looping/help


Creating Airtable records with line item support did not work. It only sees 1 line with multiple info inside.

 

I tried to add 3 steps to my ZAP to reformat the item list. The individual tests work fine on ZAPIER, but when the Zap plays in real life after publishing the ZAP, the step to parse into object says error = "SyntaxError: Unexpected token \ in JSON at position 1" because ZAPIER sees backslashes when the tests did not. The step to “unescape Quotes” is supposed to get rid of that error, but it seems that ZAPIER still sees extra backslashes in the input data, when the tests results don’t show any.

 

Can anyone help understand and fix this ?

 

 

Below are the 3 steps added to my ZAP to reformat the item list:

- to Create array from "capteurs" string {xxxx},{xxxx},.…

// this is wrapped in an `async` function // you can use await throughout the function //output = JSON.parse(inputData.capteurs); // stores an array of any length (0 or more) with the matches var matches = inputData.capteurs.match(/\{r^\}]+\}/g) // the .map function executes the nameless inner function once for each // element of the array and returns a new array with the results // {str: 'loYm9vYzE6Z-aaj5lL_Og539wFer0KfD'}, ...] return (matches || (]).map(function (m) { return {str: m} })

Results as seen on ZAPIER-test : str {"Nom du site":"site 1","Nom du capteur":"nom capteur 1","Cas d'usage du capteur":"Consommation énergétique au compteur (GAZ)"}

vs Results as seen on ZAPIER-real, with backslashes : str {\"Nom du site\":\"1\",\"Nom du capteur\":\"nom capteur 1\",\"Cas d'usage du capteur\":\"Consommation \u00e9nerg\u00e9tique au compteur (GAZ)\"}

 

- to unescape Quotes

var utility = { escapeQuotes: function(string) { return string.replace(new RegExp('"', 'g'),'\\"'); }, unescapeQuotes: function(string) { return string.replace(new RegExp('\\"', 'g'),'"'); } }; output = {"capteurs":utility.unescapeQuotes(inputData.json)};

Results as seen on ZAPIER-test : capteurs {"Nom du site":"site 1","Nom du capteur":"nom capteur 1","Cas d'usage du capteur":"Consommation énergétique au compteur (GAZ)"}

vs Results as seen on ZAPIER-real, with backslashes : capteurs {\"Nom du site\":\"a\",\"Nom du capteur\":\"1\",\"Cas d'usage du capteur\":\"Consommation \u00e9nerg\u00e9tique au compteur (GAZ)\"}

 

 

- to Parse into object "capteurs" {xxxxx}

output = JSON.parse(inputData.json);

 

Results as seen on ZAPIER-test :

Nom du site  site 1

Nom du capteur nom capteur 1

Cas d'usage du capteur Taux de remplissage des points d'apports volontaires

vs Results as seen on ZAPIER-real: error = "SyntaxError: Unexpected token \ in JSON at position 1"


Hi @DPA 

Good question.

Airtable supports creating records with line items.

 

Or try using the Looping app: https://zapier.com/apps/looping/help

Thank you, @Troy Tessalone , for your response.

 

However, Creating Airtable records with line item support did not work. It only sees 1 line with multiple info inside.

 

I tried to add 3 steps to my ZAP to reformat the item list. The individual tests work fine on ZAPIER, but when the Zap plays in real life after publishing the ZAP, the step to parse into object says error = "SyntaxError: Unexpected token \ in JSON at position 1" because ZAPIER sees backslashes when the tests did not. The step to “unescape Quotes” is supposed to get rid of that error, but it seems that ZAPIER still sees extra backslashes in the input data, when the tests results don’t show any.

 

Can anyone help understand and fix this ?

 

 

Below are the 3 steps added to my ZAP to reformat the item list:

- to Create array from "capteurs" string {xxxx},{xxxx},.…

// this is wrapped in an `async` function // you can use await throughout the function //output = JSON.parse(inputData.capteurs); // stores an array of any length (0 or more) with the matches var matches = inputData.capteurs.match(/\{.^\}]+\}/g) // the .map function executes the nameless inner function once for each // element of the array and returns a new array with the results // i{str: 'loYm9vYzE6Z-aaj5lL_Og539wFer0KfD'}, ...] return (matches || r]).map(function (m) { return {str: m} })

Results as seen on ZAPIER-test : str {"Nom du site":"site 1","Nom du capteur":"nom capteur 1","Cas d'usage du capteur":"Consommation énergétique au compteur (GAZ)"}

vs Results as seen on ZAPIER-real, with backslashes : str {\"Nom du site\":\"1\",\"Nom du capteur\":\"nom capteur 1\",\"Cas d'usage du capteur\":\"Consommation \u00e9nerg\u00e9tique au compteur (GAZ)\"}

 

- to unescape Quotes

var utility = { escapeQuotes: function(string) { return string.replace(new RegExp('"', 'g'),'\\"'); }, unescapeQuotes: function(string) { return string.replace(new RegExp('\\"', 'g'),'"'); } }; output = {"capteurs":utility.unescapeQuotes(inputData.json)};

Results as seen on ZAPIER-test : capteurs {"Nom du site":"site 1","Nom du capteur":"nom capteur 1","Cas d'usage du capteur":"Consommation énergétique au compteur (GAZ)"}

vs Results as seen on ZAPIER-real, with backslashes : capteurs {\"Nom du site\":\"a\",\"Nom du capteur\":\"1\",\"Cas d'usage du capteur\":\"Consommation \u00e9nerg\u00e9tique au compteur (GAZ)\"}

 

 

- to Parse into object "capteurs" {xxxxx}

output = JSON.parse(inputData.json);

 

Results as seen on ZAPIER-test :

Nom du site  site 1

Nom du capteur nom capteur 1

Cas d'usage du capteur Taux de remplissage des points d'apports volontaires

vs Results as seen on ZAPIER-real: error = "SyntaxError: Unexpected token \ in JSON at position 1"


@DPA 

It would be helpful to have screenshots with how each of your Zap steps are configured to make sure we have proper context.