core:clear (Delete all entries from a list)
Data structures can contain 'plural characteristics' of different types, which can be described in a simplified way as a 'list' with possibly several 'entries'.
The attribute core:clear can be used within an import structure for an update (UPDATE action) in order to remove any existing entries from such 'lists', possibly to populate them with new entries afterwards.
A list is only deleted if the attribute contains the boolean value true.
With the value false (or another value different from true) the attribute is ignored and any entries listed in the import structure are processed individually by either adding, updating or deleting (see core:delete (Delete individual elements)) list entries.
►IMPORTANT◄ Depending on the type of data structure to be cleared as a list, the procedure differs in details, as the following examples illustrate.
Example 1: Delete all values in a list
At a certain point in the life cycle of a business object of the 'order' type, all existing attributes are to be deleted by an import, so that afterwards only the attribute values provided by the same Import apply. These should mark the order as 'archived' and indicate a reference number by which archived data can be obtained, if required.
The Import shown on the right uses the action UPDATE.
►NOTE◄ The header data of the order and the item data (including attributes) remain unchanged. |
<?xml version="1.0" encoding="UTF-8"?> |
Example 2: Delete all values of a plural attribute
Via an Import from another system, 'communication information' is to be regularly synchronized into the address data for Users. If this plural attribute (see Plural attributes) contains data already, the data provided by the Import should replace it completely. In the following example, the external system only provides two e-mail addresses that are classified using the 'Context' property(communicationContext), which is evaluated when automatic notifications are sent (for example, by the Mail address user resolver).
►IMPORTANT◄ The values of a plural attribute are not stored in a dedicated list element, but appear as a group of formally independent elements of the type AddressCommunicationInfo in the list attributes, which also contains all other attributes. Therefore the core:clear attribute cannot be assigned to a parent element for 'Communication infos' in the iImport. Instead, it must appear exactly once (with the value true), namely in the first imported AddressCommunicationInfo element, to ensure that any existing entries are removed and replaced by those defined in the import.
If the purpose of the import is not to create any entries, but to delete existing entries in the list without replacing them by others, the import must still feature a dummy entry like the following, which must combine the attribute core:clear with the attribute core:delete with the value true, to prevent the creation of an empty entry:
<base:AddressCommunicationInfo core:clear="true" core:delete="true"></base:AddressCommunicationInfo>
Before the import, the 'Communication infos' shown on the right are assigned for a specific user account:
|
|
The Import shown on the right uses the action UPDATE:
|
<?xml version="1.0" encoding="UTF-8"?> |
After the import, only the two current e-mail addresses appear in the user account (for ID 4252):
|
|
Example 3: Delete all values of a typed plural attribute
In principle, the same methodology is used for a typed plural attribute as for a multiple attribute (see previous example). However, it is necessary to specify the type of typed plural attribute whose values are to be deleted.
In the following example, an Import will delete all entries for a plural text attribute 'Container No.' (CONTAINER_NO) on the header level of an order.
The Import shown on the right uses the action UPDATE:
|
<?xml version="1.0" encoding="UTF-8"?> |