Hi there, this is my first time posting on StackOverflow so I appreciate your understanding. Here is the problem I'm facing:
I have a Zap that retrieves data from a Google sheet and adds it to a JavaScript array in a document. I utilized Zapier code to create the array items. I tried two different approaches to achieve this, but encountered the same issue.
1st method: I attempted to push Zap data into a new array to modify the way it's written using the following code snippet:
/* inputData represents the array where Zapier stores your data when using Zap code
it appears like this: inputData = {com1: 'company name 1', com2: 'company name 2'}*/
var newArray = [];
var size = Object.keys(inputData).length;
console.log(size);
for (var i = 0; i < size ; i++ ){
if (inputData['com' + i] != null && inputData['com' + i] != ''){
newArray.push('\"' + inputData['com' + i] + '\" ');
} else {
}
}
var output = {company: newArray};
/* The objective here is to format the new array as follows: output = ["company name 1", "company name 2", etc]
2nd method: involved simply taking the data and utilizing it in the final step of the Zap.
BOTH methods worked fine from a syntax perspective, however, some newline issue disrupted the functionality in the end product.
The result of the array:
This is how it appears in the final product, and removing the new lines resolves the issue. I'm unsure how to resolve these new line problems or find a workaround.
company: {com0: 'company name 1
',com1: 'company name 2 //this is the issue,
',com2: 'company name 4
',com3: 'company name 4
',com4: 'company name 5
'},