Dynamically Constructing Field Formulas via Configuration Table Look Ups
I have a JSON array that I need to variably manipulate. My thought was to build a configuration table with four columns:
- A unique identifier for that row
- RegEx pattern(s) to search the JSON for specific key(s)
- The field reference I would use to overwrite the current value(s) (e.g. fields['field-name'])
- A description of what that operation will do
By using Tables: Look up data in a column, I thought to dynamically configure a Fields: Field formulas step each time the process would run, leveraging the JavaScript replace() method.
I've had some trouble trying to concatenate those operations in the Fields: Field formulas step. When I hardcode the JavaScript with the same values from the look up, the step seems to complete. If I try to concatenate the operation from what we have inferred from the table, it seems to fail.
Is there something special I should keep in mind to build a pattern like this?
Best Answer
-
I was able to get this to work by writing all of the JavaScript, including the RegEx pattern, in the reference table. When this runs, I used a Fields: Field formulas action, and referenced the returned JavaScript in a {{handlebar}} format rather than fields['field-name'] format.
0