Extract data that doesn't always exist from bundle

Hi,

I’m pretty new to Make.com and still trying to get the hang of it, so apologies if the question is a basic one.

I have a webhook I’m getting from Wix with an array of 2 custom form fields that look like this:

“custom_form_fields”: [
{
“label”: “Number of children (if any):”,
“value”: “3”
},
{
“label”: “I’ve read the T&C”,
“value”: “true”
}

I need to extract the value of the “number of children” field, but the thing is that it doesn’t always exist. If the customer doesn’t type anything and the field is empty, I only get the “I’ve read the T&C” field and the children one doesn’t exist.

I tried to do this with an Iterator and then a router with a filter (and then combining it back), but I’m pretty sure there’s a better way I didn’t think about.

Hi @SagiB

You should use the array map/get functions.


Please find the function attached; copy/paste it to your scenario and replace the custom field array with the array from a Wix module.
{{first(map(17.custom_form_fields; “value”; “label”; “Number of children (if any):”))}}

1 Like

Welcome to the Make community!

To do this, you can use the built-in function ifempty

{{ ifempty(value1; value2) }}

This way, you can set the default value to 0 if it doesn’t exist.

e.g.: (paste this into the field)

{{ ifempty(1.variable; 0) }}

For more information, the function’s documentation can be found in the Help Centre. You should also complete the tutorials in the Make Academy.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

2 Likes