What is your goal?
I want to prevent an empty field (optional address line) being passed from a Cognito form entry to a Zoho contact
What is the problem?
I have had assistance from Merlin, but I’m not sure how to put it into practice!
What have you tried so far?
This is the advice:
The removeEmpty function is a custom IML function that you need to use in the mapping area of your Zoho module, not as a separate function selector. Here’s how to implement it:
How to Use removeEmpty in Your Scenario
Instead of looking for removeEmpty as a standalone option, you need to wrap your data with the function directly in the field mapping:
Step 1: Add the removeEmpty Function
First, you need to define the removeEmpty function in your scenario. You can do this by using it in a mapping expression:
function removeEmpty(input) {
if (typeof input !== “object” || input === null) return undefined;
return Object.entries(input).reduce((acc, [key, value]) => {
if (Array.isArray(value)) {
acc[key] = value.map(item => removeEmpty(item));
return acc;
}
if (typeof value === “object” && value !== null && !(value instanceof Date)) {
if (Object.keys(value).length === 0) return acc;
acc[key] = removeEmpty(value);
return acc;
}
if (value === null) return acc;
acc[key] = value;
return acc;
}, {});
}
Step 2: Apply removeEmpty to Your Address Field
When mapping the address field in your Zoho module, instead of directly mapping the address object, wrap it with the function:
{{removeEmpty(addressObject)}}
Or if you’re mapping the entire body:
{{removeEmpty(parameters)}}
What removeEmpty Does
The function automatically:
Removes empty objects (like an empty address: {})
Removes null values
Processes nested objects and arrays recursively
Prevents validation errors from APIs that reject empty collections
This way, empty address fields from Cognito Forms will not be sent to Zoho, avoiding the “Field cannot be empty” validation errors.
Unfortunately, I cannot see how to add that function or then use it in the list of mappings
