Hi Abhilesh,
Greetings from Pabbly!
We reviewed your workflow and found that the inconsistency in mapping for cf_country_code and mobile is due to the way the incoming data is structured.
In some cases, these values are available directly at the top level of the response (e.g., "cf_country_code": "+91"), and mapping works perfectly. However, in other cases, they are embedded inside a nested field called custom_fields, which is a JSON array stored as a string.
Since Pabbly's direct mapping cannot extract values from within such stringified arrays, the mapping fails when the values are not available at the top level.
Recommended Solution:
To ensure consistent results, we suggest using the Code by Pabbly step to extract both cf_country_code and mobile from the custom_fields array. Here’s a sample code snippet you can use:
javascript
CopyEdit
let fields = JSON.parse(input.custom_fields); let result = { cf_country_code: "", mobile: "" }; for (let i = 0; i < fields.length; i++) { if (fields.api_name === "cf_country_code") { result.cf_country_code = fields.value; } if (fields.api_name === "mobile") { result.mobile = fields.value; } } return result;
This will ensure that both values are extracted correctly regardless of how the data is structured in each case.
Please feel free to reach out if you'd like help setting this up in your workflow—we’d be happy to assist you.