Filter values based on multiple values

Sure, as long as it’s smaller than 100k, you could save and re all it from a long text field. But it would have to be stringified first and parded when reading back into your script. I would focus first on making it dynamic and then if there are reasons to persist the index, work on that part separately.

The format is a JSON object; the structure is whatever you need the index to be. For example, a list of customer name keys might look like this in a variable named oCustomers:

{ "ABC Transportation" : {
   "customer_id" : "1001",
   "customer_contact" : "Jimmy Johns",
   other attributes needed for the index...
... objects representing rest of the customers ...

With such a structure, one could instantly know the customer ID with one line of code in about 2 milliseconds (i.e., all without iterating across the data table):

let customerID = oCustomers['ABC Transportation'].customer_id;

Is the o in the variable name an instance of Hungarian Notation?

1 Like

Um, no - it’s just an indicator (for my team) of a parsed JSON object. sRecords (for example) would be a serialized JSON object. Declaring (in code) the nature of JSON values is helpful where lots of integrations exist.

Isn’t that a variation of Hungarian Notation?

It’s a prefix that states metadata about the variable–in this case the variable’s data type.

I am back to this problem again trying to work in automation.

I am wanting to filter multiple records by an array. For instance – I am trying to match recipes that have wheat products in to find the ones with gluten.

Gluten will have multiple different names in the table, and I need to filter by these multiple record IDs. Is it possible to do this without hard coding the &&?

Yes, it is possible.

One way is to use the array function includes() inside a loop on the ingredients.

Another way is to make an array that includes all the ingredients and all the gluten ingredients. Then make a new array that contains only unique ingredients. Assuming that each ingredient is listed only once in a recipe, if the two arrays are the same length, there was no gluten in the original list of ingredients.