Populate empty element data

Actions – Abstract

Populates a new empty object as element data of the target element. If no target element is specified, the form itself is used.

See also: Populate element data.

images/download/attachments/189434830/image-2024-10-17_10-7-2-version-1-modificationdate-1729152422393-api-v2.png

The Populate empty element data action creates a new empty object and assigns it to a specified target element as element data.

  • The target element can optionally be explicitly assigned by a link.

  • If no target element is linked, the complete form is considered a target element.

This action is typically used to reset element data of an object that is linked via a data field to an Element containers that contains several form elements related to data fields of the object.

  • The Don't apply default values option decides whether the data fields will be assigned a default value ($init) defined for the Form elements, if any, or 'No value' ($null).

  • Populating empty element data always deletes all data fields of the data object in question that are not represented by Form elements.

  • Form elements that are not within the substructure downward from the target element, but still refer to form data changed by the action, are not automatically updated by the Populate empty element data data action. They therefore display values that may differ from the 'data state' until they are 'reloaded' with element data (see third example below for details).


images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg CAUTIONimages/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg Using the Populate empty element data action in Input forms can lead to 'breaking up' the data structure, which is basically specified there by the entity type in a binding manner. For example, setting 'empty element data' to an input form for Users would ensure that the Form elements contained in the input form no longer refer to the entity type for which the input form was opened. Inputs can then be made but no longer saved.


Examples

Simple use case

A simple portal (see Portals) is used to 'pre-record' key data from which an entity representing a 'Shipment' can be created in a second step of the workflow. To avoid duplicates, however, it should be checked beforehand whether a 'Shipment' already exists for which key values from the portal match.

For the screenshot, the names of the data fields used were entered as labels of the relevant form elements. The JSON structure on the right shows the 'structure export' for the portal, i.e. its form data.

Runtime view of the portal

JSON image of the form data
Blue: Data of form elements in the 'Details' container

images/download/attachments/189434830/image-2023-8-2_14-34-59-version-1-modificationdate-1729152132822-api-v2.png

{
"trackingId": "XQ10245122561286432",
"requestedDate": {
"clazz": "de.lobster.scm.utils.date.DateRange",
"timeZone": "Africa/Cairo",
"start": "1593820800000",
"end": "1593820800000"
},
"cne": {
"clazz": "java.lang.Long",
"value": "4101"
}
}

When the RESET Button below the trackingId text field is clicked, the Form elements to the right of the Button element, which are in a Column layout container with the button element, should be 'reset'.

If available, the default values of the contained Form elements should be assigned to the data fields. Otherwise: 'No value' ($null).

Configuration:


images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg CAUTIONimages/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg The following configuration only 'nearly' works. It is intended to document a common misconception that can lead to unexpected results. The 'Remeby' section refers to working solutions.


A behaviour with the name 'reset' is set up for the Button and configured as shown on the right:

  • The Click Triggering event is selected, as is typical for a Button.

  • The Behaviour type Static with the (default) value 'ON/True' ensures that every time the Button is clicked, the Actions on 'true' are executed unconditionally.

  • The only action to be executed is a Populate empty element data. This action is linked to the No target element linked, which is the container that is to be 'reset'.

  • Deviating from the standard (selected) will uncheck the Don't apply default values, so that they may be considered if necessary

images/download/attachments/189434830/image-2024-10-17_10-9-22-version-1-modificationdate-1729152562336-api-v2.png

Runtime example:

Process step

Runtime view of the portal

JSON image of the form data
blue: Data of form elements in the 'Details' container
red: Deviating ('outdated') data status for 'Details'

The portal has just been opened:

The screenshot on the right shows the portal with the default values defined in the layout:

No default value is provided for the other fields (confirmedDate, cne).

images/download/attachments/189434830/image-2023-8-2_14-39-44-version-1-modificationdate-1729152132817-api-v2.png

{
"trackingId": "XQ",
"requestedDate": {
"clazz": "de.lobster.scm.utils.date.DateRange",
"timeZone": "Africa/Cairo",
"start": "1691013600000",
"end": "1691013600000"
}
}

The portal was edited:

  • A trackingId has been entered,

  • The requestedDate has been changed.

  • A cne ('consignee') has been selected.

The form data (see last column) reflects the changes to the form elements inside (blue) and outside (black) the 'Details' container.

images/download/attachments/189434830/image-2023-8-2_14-41-48-version-1-modificationdate-1729152132814-api-v2.png

{
"trackingId": "XQ10245122561286432",
"requestedDate": {
"clazz": "de.lobster.scm.utils.date.DateRange",
"timeZone": "Africa/Cairo",
"start": "1593993600000",
"end": "1593993600000"
},
"confirmedDate": null,
"cne": {
"clazz": "java.lang.Long",
"value": "4402"
}
}

The 'RESET' Button was clicked:

  • The Form elements inside the (invisible) 'Details' container show the same values as opening the portal (see first step).

  • The trackingId field still shows the entered string.

Therefore, it looks like the RESET Button via the Populate empty element data action had the desired effect and only reset the 'Details'.

However, this is a misconception, as a look at the form data proves!

images/download/attachments/189434830/image-2023-8-2_14-44-9-version-1-modificationdate-1729152132811-api-v2.png

{
"trackingId": "XQ10245122561286432",
"requestedDate": {
"clazz": "de.lobster.scm.utils.date.DateRange",
"timeZone": "Africa/Cairo",
"start": "1593993600000",
"end": "1593993600000"
},
"confirmedDate": null,
"cne": {
"clazz": "java.lang.Long",
"value": "4402"
}
}

The form data for elements in the 'Details' container, which was previously displayed in blue , now differs from the current values in the container and is therefore displayed in red .
For the supposedly 'reset' data fields, the form data still contains the values from the previous step.

A changed string was entered in the trackingId Text field:

  • The form data for the trackingId field continues to reflect the change, which may reinforce the false impression that the RESET works successfully.

  • The data for elements in the 'Details' container still differs from the form data, which is therefore shown here in red.

images/download/attachments/189434830/image-2023-8-2_14-47-41-version-1-modificationdate-1729152132808-api-v2.png

{
"trackingId": "XQ123456789",
"requestedDate": {
"clazz": "de.lobster.scm.utils.date.DateRange",
"timeZone": "Africa/Cairo",
"start": "1593993600000",
"end": "1593993600000"
},
"cne": {
"clazz": "java.lang.Long",
"value": "4402"
}
}

What happened?

  • Since the Populate empty element data action was applied here to a container that does not have its own data field associated with it, the action destroys the connection of the Form elements to the form data within the container.

  • Form elements in the 'emptied' container work fine on the surface, but no longer have any influence on the form data.

  • Form elements outside the 'emptied' container continue to be related to the form data as usual.

Remedy:

  • A data field (details) can be associated with the 'Details' container. Then the Populate empty element data action refers to this data field because it is associated with the 'Details' element.

    • The action then deletes all data in the details field, including data in fields that are not represented by Form elements at all in the portal, but were already included in the form data when it was opened.

    • If Form elements are present in the container, their default value assignments for data fields will be taken into account if the Don't apply default values option is unchecked.

    • Of course, the data field (details) then also appears as an object ("details":{ ... }) in the structure of the form data and summarizes the associated element data.

  • Alternatively, the link for the Target element could also be removed. Then the Populate empty element data action applies to the entire form.

    • The action then creates a completely new 'client object' and assigns it as form data (formData). Thereby all Form elements are linked to this new data object.

    • If the option Don't apply default values is unchecked, the default values defined for Form elements, if any, will also be set.

    • The input for the trackingId Text field is of course also lost. In the example, the default text 'XQ' appears instead.

More complex use case

In the use case from the previous example, the portal should fulfill additional requirements:

In addition to the 'Details' of the shipment shown above, some specific characteristics for the contents of the shipment should be selectable/unselectable as flags (flags):

  • 'Dangerous goods' (danger)

  • 'Biological hazards' (bioHazard)

  • 'Animal transport' (livestock)

  • 'Reusable packaging' (returnable)

  • 'Insurance' (insurance)

In the screenshot on the right, the names of the data fields are again displayed as labels.

In the JSON image of the form data (far right), the data of the indicators grouped in a field/object flags are highlighted in blue .

The insurance (insurance) flag should be selected by default. All others are unselected.

images/download/attachments/189434830/image-2023-8-2_15-5-28-version-1-modificationdate-1729152132805-api-v2.png

{
"details": {
...

},
"flags": {
"insurance": true,
"danger": null,
"bioHazard": true,
"livestock": true, "returnable": false,

},
"trackingId": "XQ123456789"
}

As seen in the screenshot, the portal should be able to be reset gradually:

  • The RESET Button at the very top is to reset the portal altogether.

  • The RESET Button to the left of the tab panel element should reset the contents of the tabs for details and flags.

  • The RESET Button in the flags tab should exclusively reset the flags available in this tab.

Configuration:

As stated in the previous example, the Populate empty element data action should be applied to Element containers if they are related to a data object via a data field whose data is to be 'deleted' and then enriched with default values from the form elements in the container, if necessary.

  • As shown in the form data above, in addition to the 'Details' field (see previous example), there is a 'Flags' field that combines all indicators as Boolean fields in one object.

  • Obviously there is no parent field/object that merges 'all data in the Tab panel element'.

The 'resetFlags' behaviour on the right is configured for the RESET Button in the flags tab:

  • As usual for a Button, the Triggering event Click is assigned here as well.

  • The Behaviour Static (with the option 'true') also ensures that the Actions on 'true' are executed unconditionally.

  • The Populate empty element data action refers to the tab element 'flags' as the Target element. The option Don't apply default values is unchecked as in the first example.

NOTE◄ The screenshot shows the default values for the Check box elements in the flags tab:

  • The Insurance Check box is 'ON'.

  • All others are 'OFF' by default.


images/download/attachments/189434830/image-2023-8-2_15-24-3-version-1-modificationdate-1729152132802-api-v2.png

As long as there is no parent data field for all data in the Tab panel element, the 'resetting' of the two tabs must be solved this way:

The 'reset' behaviour on the right is configured for the RESET ► Button to the left of the Tab panel element:

  • As usual for a Button, the Triggering event Click is assigned here as well.

  • The Behaviour Static (with the option 'true') also ensures that the Actions on 'true' are executed unconditionally.

  • The Populate empty element data action is called twice here with different Target element links to 'reset' each tab individually. In both cases the option Don't apply default values is unchecked.

NOTE◄ The only way to simplify the procedure is to address a higher-level data field. However, this would then also inevitably appear in the data structure of the form data..

Instead of the second call of the Populate empty element data action, the 'resetFlags' behaviour could also be called via an Execute behaviour action. This would ensure that the same logic (e.g. for the option Don't apply default values) reliably applies for resetting the flags in both cases.

images/download/attachments/189434830/image-2024-10-30_15-48-47-version-1-modificationdate-1730299726998-api-v2.png

Runtime example:

images/download/attachments/189434830/image-2023-8-1_17-28-40-version-1-modificationdate-1729152132852-api-v2.png







─ Klick ─►

images/download/attachments/189434830/image-2023-8-1_18-9-23-version-1-modificationdate-1729152132847-api-v2.png

{
"details": {
"requestedDate": {
"clazz": "de.lobster.scm.utils.date.DateRange",
"timeZone": "Africa/Cairo",
"start": "1691013600000",
"end": "1691013600000"

}
},
"flags": {
"insurance": true
},
"trackingId": "XQ123456789"
}

Clicking the RESET Button in the flags tab will exclusively reset the data in the "flags" field, while the data in the "details" field and the trackingId will be preserved.

Even more complex use case

The use case from the previous example is now to be made even more 'complicated' in order to show another potential conflict in the context of the Populate empty element data action and a mitigation possibility:

At the header level of the portal, an additional 'test' indicator is offered, which can be used to signal that the input is test data. The feature can, for example, control whether certain steps in a triggered workflow take place or not.

As can be seen in the screenshot on the right, not only the mimic (icon and check box with display type 'toggle box') is based on the configurations in the flags tab. Also the reference to the data field name flags.text in the caption makes clear that the flag should be located together with the others in the field/object "flags", although it is placed in the form header.

images/download/attachments/189434830/image-2023-8-2_10-17-52-version-1-modificationdate-1729152132839-api-v2.png

{
"details": {
...
},
"flags": {
"test": true,
"insurance": true
},
"trackingId": "XQ"
}

NOTE◄ As the JSON image of the form data above shows, the "test" flag (highlighted in blue above) appears as desired along with the other flags in the "flags" field when selected or 'turned on' as in the image.

The extension seems to work as desired at first. However, the use of the Populate empty element data action within the flags tab raises critical questions:

  • Is the "test" flag deleted when the RESET Button in the flags tab is pressed?

  • Is the relationship between the form data and the Check box element in the header damaged by the reset?

  • Is a default value (ON) set for the check box element when the RESET ▼ Button in the flags tab executes the Populate empty element data action with Don't apply default values unchecked?

We clarify this step by step below:

Runtime example:

images/download/attachments/189434830/image-2023-8-2_10-17-52-version-1-modificationdate-1729152132839-api-v22.png


Initial situation:

  • The 'test' flag is assigned the default value 'Selected'.

  • In the flags tab only the Insurance flag is selected. This corresponds to our default state, which is also expected after a 'RESET'.

Clicking the RESET ▼ Button in the flags tab does not change the appearance of the portal in this situation.

JSON image of the form data after the 'RESET':

{
"details": {
... },
"flags": {
"insurance": true
},
"trackingId": "XQ"
}


IMPORTANT

  • The Populate empty element data action assigns a new 'empty' data object with the default value (true) for the "insurance" flag to the "flags" field. This also deletes the "test" flag from the form data.

  • The Check box outside the flags tab will not be updated by the action, nor will its default value be taken into account.

The resulting 'imbalance' between the display of the "test" Check box and the form data, does not correct itself:

  • The data field references flags.test and would pull the current value (false/null) from the 'reset' data for the flags field/object if the Check box element 'asks'.

  • Interactively, the Check box could be turned off. Then the Check box element and the form data would be synchronized again. But this step should certainly not be left to the user.

Remedy:

In order to ensure that after a 'RESET' in the flags tab, all Form elements outside the tab also take the changed form data into account, the Reload element data action should be executed directly after the action Populate empty element data:

  • Here, we explicitly link the entire form as the Target element.

  • The Don't apply default values option is unchecked here so that defined default values are assigned to empty fields if necessary.

IMPORTANT◄ Assigning default values affects all Form elements that refer to data fields for which the form data does not contain a value ($null), and not just those 'emptied' by the previous action, for example. In this respect, there are certainly also scenarios in which it may make sense to treat the Don't apply default values option differently in both actions.

images/download/attachments/189434830/image-2024-10-30_16-3-41-version-1-modificationdate-1730300620842-api-v2.png