Chceck if collection contains value

On this screenshot You can see part of my webhook and my soluution to check if one of values of custom field 10 contains “Foto”. If yes, the field shoud get value “Zamówiony” and “Nie” if not. Right now my sollotion always tells me that the answer is “Nie”.

Should I use something else than “contains”?

Hey!

In fact, your data it not an array. It’s a collection. It means that you need to test value.0, value.1, and value.2

You could just concatenate these 3 values, or compare the result.

1 Like

What Ben says is correct.

You can use the join function to combine the array items into a single string, or you can provide your output bundle so others can come up with a better solution.

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of each module and select “Download output bundles”.
Screenshot_2023-10-06_141025

A.

Save the bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading it here will look like this:

bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted output bundle in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

samliewrequest private consultation

Join the unofficial Make Discord server to chat with us!

2 Likes

This time I testen with if the values of collection, but I think that something is still wrong with my sollution :frowning:

{{if(1.appointment.bookings.0.customFields.10.value.0 + “,” + 1.appointment.bookings.0.customFields.10.value.1 + “,” + 1.appointment.bookings.0.customFields.10.value.2 + “,” + 1.appointment.bookings.0.customFields.10.value.3 + “,” + 1.appointment.bookings.0.customFields.10.value.4 + “,” + 1.appointment.bookings.0.customFields.10.value.4 + “,” + 1.appointment.bookings.0.customFields.10.value.5 + “,” + (1.appointment.bookings.0.customFields.10.value.6 = “Foto”); “Zamówiony”; “Nie”)}}

Hey @krzysztof114 !

From your information, you can end-up comparing “Foto,,,,,,,” which won’t work. I have 2 questions for you before I can help you:

  • Does your webhook ALWAYS receive the data in the same format? appointment.bookings.0.customFields.10.value.X?
  • Do you want to see if ONE of the fields is equal to Foto? Or only the field “0”?

Benjamin

1 Like

Hi and thanks in advance :slight_smile:

This custom field could be from one to six values. Lests say its somethink like: apple, pineapple, banana, so webhook can give me apple in one respond, pineapple, banana in the other, and only banana next time.

I want to know in one of this all values is Foto. In some cases field 0 could get me diferent values than Foto.

1 Like

Then, one easy way to do is to use the “contains” function as well. Like this

Example

Contains will return “true” if one field has Foto. So IF with return Zamówiony

1 Like

Works like a charm. Thanks a lot. When GPT fails you @Benjamin_from_Make is the man!

3 Likes

Well I guess that being better than GPT is a compliment, so thank you!!! :joy:
Thanks for your feedback! And good luck for your project

Benjamin