In the change list activity, introduce a new (default) Type that only adds object(s) to the list that are not already on the List. - Mendix Forum

In the change list activity, introduce a new (default) Type that only adds object(s) to the list that are not already on the List.

0

By default, the Mendix micrioflow/nanoflow activity 'Change List' with type 'Add' selected, will always add the value (containing a single object or a list of objects) to the selected List. Even if this value, say object, already is on the list.

 

This default behavior is useful, but may quickly require dealing with unwanted list duplicates (i.e. by using the union list action for example) which could be easier to prevent if there was a different type of 'change list' behavior available.

 

The proposal would be to introduce a behavior 'type' that checks for all objects to be added to the list, if that object is already present on the list. If not, it is added. If already on the list, the following is evaluated:

- If the object instance on the list is the same instance that is to be added, there is no need to add it again an is therefore effectively ignored

- If a different instance of the object is required to be added (this can be caused by another database retrieve of the same object that is already on the list):

- Option 1: only the instance with 'the newest database version' is kept/put on the list. If both have the same version an error is thrown that indicates this discrepancy.

- Option 2: the instance on the list is always replaced by the instance to be added.

 

This option would add 'easy to use' list manipulation and in a sense add a 'data consistency' check to the change list (Add to list) activity if option 1 is chosen. The proposed above can be realized in a subflow, but this is cumbersome since this flow would need to be created for every object-type (i.e. entity) that uses the 'add to list' action. The downside of this proposal would be reduced performance since a check is required for all objects that are to be added, which becomes more demanding when dealing with a large list size. In addition, if option 1 is chosen, the 'error state' needs to be taken into account in error-handling. 

asked
0 answers