pfx-api:save

pfx-api:save

Save (create or full-replace) a single record in Pricefx. The exchange body must be a data map that includes the typedId field identifying the record.


Parameters

Parameter

Type

Default

Description

objectType

ObjectType (enum)

--

The Pricefx object type to save (e.g., P, C, PL, PX, etc.).

typedId

String

--

The typedId of the record. Can also be provided inside the body map.

mapper

String

--

Optional mapper bean name to transform the body before saving.


Body Requirements

The exchange body must be a data map (Map<String, Object>) representing the full record. The map should include the typedId field to identify the record. If the record exists, it is replaced; if it does not exist, it is created.


XML Route Examples

Save a product record

XML
<route>
    <from uri="direct:saveProduct"/>
    <!-- Body should be a Map including typedId, e.g., {"typedId": "123.P", "sku": "SKU001", "label": "My Product"} -->
    <to uri="pfx-api:save?objectType=P"/>
</route>

Save with explicit typedId

XML
<route>
    <from uri="direct:saveWithTypedId"/>
    <to uri="pfx-api:save?objectType=P&amp;typedId=123.P"/>
</route>

Save with a mapper

Use a mapper to transform the incoming data before saving:

XML
<route>
    <from uri="direct:saveWithMapper"/>
    <to uri="pfx-api:save?objectType=P&amp;mapper=productSaveMapper"/>
</route>

Common Pitfalls

  • Body must include typedId: The body map must contain a typedId field (or the typedId URI parameter must be set). Without it, the save operation cannot identify the target record.

  • Full replace, not partial update: Unlike pfx-api:update, the save method performs a full replacement of the record. Fields not present in the body map may be reset to their defaults. Use update for partial modifications.

  • Body must be a Map: The exchange body must be a Map<String, Object>. Other types (JSON strings, POJOs) are not automatically converted.

  • Object type must match: Ensure the typedId suffix corresponds to the objectType parameter.