Record Import Step
pre_upsert_records takes a list of records, usually the body of an
http_get, and creates or updates one Promptless CPT Pages record for each.
It needs Promptless CPT Pages 0.9.0 or later (0.10.0 or later for
featured_image_url); without it the step fails with dependency_missing.
The full workflow around it is in Importing records.
Settings
Section titled “Settings”| Setting | Required | What it does | Default |
|---|---|---|---|
post_type | Yes | The record type’s slug, registered in Promptless CPT Pages. | — |
source | Yes | A short, permanent key for the system the records come from, such as recdesk. | — |
records | Yes | The list, usually "{{ steps.fetch.body.items }}". An object of records is treated as a list. | — |
map | Yes | How each record becomes a CPT Pages record; see below. | — |
expect_min_records | No | Fail if fewer records arrive. | 1 |
max_failure_ratio | No | Fail if more than this share of records cannot be written, from 0 to 1. | 0.1 |
missing_upstream | No | keep or draft: what to do with records of this source the list no longer contains. | keep |
The map
Section titled “The map”The map is filled in once per record, with the current record available as
{{ item.<field> }}. Other paths (vars, steps, now()) work too.
| Key | Required | What it sets |
|---|---|---|
external_id | Yes | The record’s id in the other system. With post_type and source, it is the record’s identity. |
title | Yes | The title. |
content, excerpt | No | The body and the excerpt. |
status | No | The WordPress status, such as publish or draft. A new record without one is published; an existing one keeps its status. |
fields | No | An object of CPT Pages field keys and values. |
taxonomies | No | An object of taxonomy slugs and terms: a list, or text separated by commas. |
featured_image_id | No | A Media Library attachment id. |
featured_image_url | No | An image address. It is downloaded once per address and reused on later runs. |
"map": { "external_id": "{{ item.id }}", "title": "{{ item.name }}", "fields": { "event_start": "{{ item.startDate }}", "location": "{{ item.facility.name }}" }, "taxonomies": { "program_category": "{{ item.category }}" }}What happens to each record
Section titled “What happens to each record”| Result | When |
|---|---|
| Created | No record of this type has this source and external_id. |
| Updated | One exists and the mapped values changed. Only the keys in the map are written. |
| Unchanged | One exists and nothing in the mapped values changed. Nothing is written. |
| Failed | external_id or title came out empty, or CPT Pages refused the record. Listed in failed; the other records carry on. |
After every record, the step checks its guards:
- fewer than
expect_min_recordsrecords arrived: the step fails withupstream_shapebefore writing anything; - more than
max_failure_ratioof them failed: the step fails withupstream_shape; the records already written stay.
Only when both guards pass and missing_upstream is draft are published
records of this source that were not in the list switched to draft. Records
are never deleted.
Output
Section titled “Output”| Field | What it holds |
|---|---|
received_count | Records in the list. |
created_count, updated_count, unchanged_count, failed_count, drafted_count | Counts by result. |
created_ids, updated_ids, unchanged_ids, drafted_ids | The post ids. |
failed | Each failure’s index, external_id and error. |
warnings | Map paths missing on some records (with counts), and taxonomy or image problems. |
The run history records the map as written, not filled in.
Available since FlowMint Workflows 0.8.0.