Skip to content

Actions

Actions let an automation make decisions about individual records. For example, an action can set stock to zero when a supplier reports that an item is unavailable.

Add actions inside an entry in file_configs. Use vendor_actions to test values from the incoming or outgoing record, or suredone_actions to test values already saved in SureDone. The condition selects which record to test; an action such as setValue changes the value being processed. The names used in an action are SureDone field names after mapping. Make sure the fields needed by the action are available through field_map or field_run.

Each action object may contain a search condition. When the condition matches, its functions run in the order written. Without a condition, they apply to every record processed by that action. Actions targeting an identifier, and the earlier actions in the same list, run before matching. Pre-match SureDone identifier actions are supported for products, not orders.

{
  "field_map": {"guid": "supplier_sku", "stock": "quantity"},
  "field_run": {"availability": "availability"},
  "vendor_actions": [
    {
      "search": "availability:=\"Unavailable\"",
      "setValue": {"stock": 0}
    }
  ]
}

This is a file-configuration fragment, not a complete automation. It sets stock to zero when the mapped availability field equals Unavailable. field_run makes that field available for the condition without including it as an imported field. Adapt the source column names and values to your data.

Available actions

The configuration accepts the following action names. Support for a particular action can vary when processing nested order items; test the exact workflow before relying on it.

Action What it does Argument
setValue Sets a field to a value. Object mapping field names to values.
ignoreValue, ignoreField Keeps the SureDone value instead of the incoming value. These names are aliases. Field name.
remapField Uses the value of another mapped field. Object mapping target fields to source fields.
ignoreItem, ignoreObject Skips the current item. These names are aliases. Empty string.
ignoreOrder Skips the order. Empty string.
min, max, sum, subtract, multiply, divide Calculates a value from fields and numbers. Object mapping target fields to arrays of operands.
round Rounds a value to a decimal precision. Object mapping fields to precision values.
roundUp, roundDown Rounds a value up or down to a specified decimal ending. Object mapping fields to endings.
roundNearest Rounds using a base and an ending. Object mapping fields to { "base": ..., "ending": ... }.
autoIncrement Generates a sequence. Object mapping fields to optional start and step values, each defaulting to 1.
setAddress Changes the destination address for a qualifying individual export. Address string; email uses the record's email field. Requires a template and payload_multi: false.
replace Replaces text in a field. Object mapping fields to search-and-replacement pairs.
regexExtract Extracts a match from a field. Object mapping fields to regex and optional capture_group.
convertDateTime Converts a date or timestamp to the requested format in UTC. Object mapping fields to PHP date format strings.
jsonEncode, base64Encode, base64Decode Encodes or decodes a field. Invalid Base64 input is retained. Object whose keys are fields and whose values are empty strings.
combine Joins values from fields into one field. Object mapping target fields to fields, optional delimiter, and optional ignore_empty.
uppercase, lowercase Changes a field's letter case. Field name.

For example, "combine": {"title": {"fields": ["brand", "mpn"], "delimiter": " "}} joins the mapped brand and mpn values into title. When ignore_empty is true, the implementation omits false-like values as well as empty strings; check that this is appropriate for your data.

For calculations, operands are processed in order. A field name selects its current mapped value; a number is a constant. For example, "multiply": {"price": ["cost", 1.25]} calculates price from the mapped cost. Test with the actual fields and representative values before enabling the automation.