Dynamically Constructing Field Formulas via Configuration Table Look Ups

Options

I have a JSON array that I need to variably manipulate. My thought was to build a configuration table with four columns:

  1. A unique identifier for that row
  2. RegEx pattern(s) to search the JSON for specific key(s)
  3. The field reference I would use to overwrite the current value(s) (e.g. fields['field-name'])
  4. 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

  • Thomas_937381
    Thomas_937381 Posts: 196
    Answer ✓
    Options

    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.