core:delete (Delete individual elements)
See also: core:clear (Delete all entries from a list)
As XML attribute
With the control attribute core:delete individual elements (e.g. attributes or positions) can be deleted from a data item by Import.
The attribute must always be assigned to the element to be deleted.
As with updating, the element in question must be unambiguously identified for it to be effectively deleted. Depending on the element type, this may be achieved by various methods as illustrated the examples below.
►NOTE◄ If the Import specifies the control attribute core:delete for an element that does not yet exist as a data item, it is not created by the Import. This technique is used, for example, to completely clear Plural attributes (see examples for core:clear (Delete all entries from a list)).
►NOTE◄ In simple lists that do not support unique access to the contained entries, entries cannot be individually updated or deleted. Such lists can only be completely cleared and refilled using core:clear (see core:clear (Delete all entries from a list)). This concerns, for example, the enumerations for roles (roles) and companies (companies) for a user.
As XML node
In addition, core:delete can also be used as a node whose text value contains the name of the field to be 'deleted'. There can be several core:delete nodes in one hierarchy level.
The node variant is needed to explicitly set simple fields of a business object to zero. This would not be easily possible since fields with empty or null values are ignored by an import in UPDATE mode.
Furthermore, fields with numeric type would be converted to 0 by the _data Integration Unit.
Example: <core:delete>attributes</core:delete> Deletes all attributes of a business object.
►NOTE◄ Fields marked with core:delete nodes are reset regardless of the value of the associated field. Thus, only the visibility of the core:delete node decides whether the field is reset or not.
Example 1: Removing a typed attribute identified by type
An order includes the date attribute 'Fixed delivery date'. An Import should remove values for this attribute under certain conditions (for example, because a cancellation is flagged by the leading system). This condition can be defined by assigning the value true or false to the attribute field core:delete_attr in the mapping for the import profile by a suitable function.
The Import shown on the right uses the action UPDATE.
|
<?xml version="1.0" encoding="UTF-8"?> |
►CAUTION◄ While it is irrelevant for the execution of the Import profile whether the date attribute is available in the purchase order, the profile is terminated with an error message if the specified Date types is unknown in Lobster Data Platform / Orchestration.
Example 2: Removing an order item identified by 'Pos. no'.
An Import shall remove the first entry for a certain Line item type ('service item' with the internal prefix SER) from an order.
The Import shown on the right uses the action UPDATE.
The first 'service item' is deleted, if available. |
<?xml version="1.0" encoding="UTF-8"?> |
Example 3: Removing an entry identified by index for a plural attribute
An Import shall remove the second entry for the plural text attribute 'Container No.' from a purchase order.
The Import shown on the right uses the action UPDATE.
The second 'Container No.' is deleted, if available. |
<?xml version="1.0" encoding="UTF-8"?> |
►NOTE◄ Instead of the index, which is explicitly featured as an XML-attribute for the values of plural attributes, you could also refer to the internal index per core:index attribute. However, the index value must then be assigned within the attribute node itself and not the value subnode:
<?xml version="1.0" encoding="UTF-8"?> |
Example 4: Reset/delete the value of a simple object field
The Import XML shown on the right searches for and updates an order and resets the value of the field "numberOfPackages" to zero. |
<? xml version = "1.0" encoding = "UTF-8" ?> < core :Import ... action = "UPDATE" > < search > ... </ search > < ord :Order> < core :delete>numberOfPackages</ core :delete> </ ord :Order> </ core :Import> |