Mapping and formatting fields
Mapping tells an automation how a field in the other system corresponds to a SureDone field. field_map uses SureDone field names as keys and the source or destination field names as values. Fields mapped with field_run are available for processing but are not included as ordinary output fields.
For example, an import that maps "stock": "available_quantity" reads the supplier column named available_quantity into the SureDone stock field. You can use field_map_default as a secondary mapping for supported structured data when the primary source field is absent. value_map translates values, and value_map_default supplies default values. In an import, a default can replace an empty value, including zero, when a value-map entry has not already matched. Verify missing, empty, and zero values with a representative sample before enabling updates.
Format a value
field_format applies functions to mapped SureDone field names for imports and exports. Functions on a field run in the order written. The supported functions include decimalPlaces, moveDecimal, lowercase, uppercase, combine, trim, trimLeft, trimRight, stripTags, and maxLength.
{
"field_format": {
"longdescription": {
"stripTags": "",
"maxLength": 5000
}
}
}
Here, HTML is converted to plain text before the result is limited to 5,000 characters. maxLength counts characters rather than bytes. In an export, use the SureDone field name as the key even when the destination column has a different name.
decimalPlaces rounds to the requested precision. moveDecimal divides by ten raised to the specified number of places; a positive value moves the decimal point left. trim, trimLeft, and trimRight remove characters at the ends of a value; an empty argument removes whitespace. combine joins values from listed fields, using - by default or an explicit delimiter. Function names can use camelCase or snake_case.
Calculate a value
For product exports, field_calculate can apply sumFields before actions. It adds the listed source fields to the target's existing value, or starts at zero when the target is absent:
{
"field_calculate": {
"totalstock": {"sumFields": ["warehouse_a", "warehouse_b"]}
}
}
Include the fields needed by the calculation in the mapping. Test how blanks and unexpected values in the incoming data affect the result.