Javascript to isolate a string from a string turned array

Adam_636382
Adam_636382 Posts: 32
edited December 2019 in Questions

First I'm using "Excel: Extract cell data" to get a range (single row) of data. This is generating a JSON array but from what I've gathered it can be treated as a string when applied to javascript.
I'm then attempting to use Field Formulas to pull out specific values from a csv string.
The string I have in testing is "[["product 1,,,,100,200,A123"]]". I apply .replace a few times to remove the brackets and quotes. I'm then trying to use a split to turn the string into an array and then a slice to get out the specific strings I want into their own fields.

The above formula accurately produces the intended result ("A123").

However the formula above here is producing the entire string rather than just the first index ("product 1,,,,100,200,A123"). Am I doing something wrong?
Is there a better way I can be doing this that doesn't require 7 different actions to get all the values from the Excel file in that row?

Tagged:

Best Answer

Answers

  • Jeff_146001
    Jeff_146001 Posts: 296 admin

    @Adam_636382 A potential alternative approach... Have you looked into the action, Excel: Look up data in columns?

    This can return up to 5 cells mapped to field names of your choice. If you need 7 fields, you would need 2 of these actions, but it might get you want you need without needing to get into JavaScript formulas at all.