Unable to get contains() to work on an array

Hi everyone, I apologise for missing something that must be blindingly obvious… After searching on this forum and in the Make documentation, I’m unable to find what’s wrong here:

Goal I’m trying to set the variable Var_Newclient to true if a client’s name is not found in an array containing a list of existing clients.

Steps

STEP 1 List clients in a column in a Google Sheet; returns the same number of bundles as there are rows in the Google Sheet. Clients are in column C. Looks like this:

STEP 2 Aggregates bundles into an array. Looks like this:
image
image

STEP 3 If Accor (for example) is not found in the array, set Var_Newclient to true.

OVERVIEW

Result Even though Accor IS in the array, the contains() function never returns true.

Thank you very much in advance for your help!

Welcome to the Make community!

This seems like a complex scenario you’re trying to make, perhaps exporting the blueprint might help others replicate the issue to be able to answer your question.

At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826

Uploading it here will look like this:

blueprint.json (123.4 KB)

2 Likes

Hi @Bruno1

It looks like your array doesn’t contain plain text or dates, but contains objects.
Every object has a property C which contains the value you want to be filtering.

Within the ‘set variable’ component, try changing 121. Array[] into map(121. Array[];C)

More information on the map function can be found here:
https://www.make.com/en/help/functions/array-functions

Let me know if this helps, thanks!

1 Like

Thank you folks, really appreciate your taking a look.

@samliew > Good point, thanks. I attach it here. I’ve isolated the 3 modules from OVERVIEW in my initial post, otherwise it’s a 15,000-line JSON.

blueprint (1).json (26.9 KB)

@Loopz > Thanks! That sounded relevant, but I tried and unfortunately it still doesn’t work. Before even using if(), I’ve tried with contains() + map(), and the below generates false despite “Accor” being in 121.array:



image

Looking forward to your further thoughts :crossed_fingers:

Got it @Bruno1,

Use the map function like before. Instead of putting C as parameter, you put 0. That is because C is the label of the key, the the actual key is 0. If you hover with the cursor above key C, you’ll notice

see screenshot:

3 Likes

Thank you so much @Loopz ! That’s it. I knew it would be something so basic like this…

Many thanks, all.

3 Likes