The Data Merging Component was developed to resolve data conflicts in real-time in OutSystems applications, where multiple users access and edit the same complex data structure simultaneously. It provides an automated merge process (similar to Service Studio), with support for manual conflict resolution when necessary.
Automatic data merging based on three versions: original, active (server), and edited.
Conflict resolution similar to Service Studio, where the user can choose which value to keep.
100% front-end execution, reducing server load and improving performance.
Lodash library usage for efficient manipulation of complex JSON objects.
Reusable visual block for user conflict selection.
To perform the merging process, the user needs to provide the following three JSON objects as input in the MergeJSONVersion action:
MergeJSONVersion
OriginalJSON – The original structure loaded on the screen.
OriginalJSON
ActiveJSON – The most recent version of the structure saved on the server.
ActiveJSON
NewJSON – The structure modified locally after the server version.
NewJSON
OriginalJSON: The original JSON initially loaded.
ActiveJSON: The current version of the JSON saved on the server.
NewJSON: The JSON with the modifications made locally by the user.
Return: A structure indicating whether the operation was successful or if an error occurred.
Return
MergedJSON: The resulting JSON after the merge, considering NewJSON changes as the default in case of conflicts.
MergedJSON
SimilarChanges: A list containing fields with similar/conflicting changes between ActiveJSON and NewJSON.
SimilarChanges
Different changes → automatic merge.
Conflicts on the same fields → NewJSON's value takes precedence, unless the user opts to choose manually.
The SimilarChanges list can be used to display a visual block with choices for the user.
A UI block that allows the end-user to visualize and choose the correct values for fields that have conflicts between ActiveJSON and NewJSON.
SimilarChanges: A list containing fields with similar or conflicting changes between ActiveJSON and NewJSON.
OldJSON: The original JSON initially loaded.
OldJSON
NewJSON: The JSON locally modified by the user.
MergedJSON: The resulting JSON from the merge, containing the automatic merge changes.
ReturnNewJSON: Returns the final JSON with the values selected by the user for the conflicting fields.
ReturnNewJSON
Add the SimilarChanges block in a pop-up modal.
Execute the MergeJSONVersion(OriginalJSON, ActiveJSON, NewJSON) action.
MergeJSONVersion(OriginalJSON, ActiveJSON, NewJSON)
Check the SimilarChanges list:
If there are conflicts, open the pop-up and pass the parameters to the block.
The user resolves the conflicts visually, and in the ReturnNewJSON event, the application receives the final adjusted JSON to be saved or processed as needed.
Scenario:
A form with hierarchical data (e.g., customer registration with contacts and preferences) is being edited by two users.
User A loads the data and stores the OriginalJSON.
They make modifications and save, updating the ActiveJSON on the server.
User B, who still had the older structure loaded, modifies the data and creates their own NewJSON.
Before saving:
The application executes MergeJSONVersion(OriginalJSON, ActiveJSON, NewJSON).
The action returns:
MergedJSON: With the merged changes, considering NewJSON as the priority in conflicts.
SimilarChanges: A list of fields with similar changes in ActiveJSON and NewJSON.
If SimilarChanges is not empty:
The application opens the SimilarChanges block in a pop-up.
Pass the parameters: OldJSON, NewJSON, and MergedJSON.
The user selects the desired values.
The block returns the final JSON in the ReturnNewJSON event, which can then be saved or processed according to the business logic.
Prevents accidental overwriting in collaborative environments.
The merge logic on the front-end improves performance and user experience.
Integration with Lodash makes the component robust and efficient for handling nested objects.
The visual block makes conflict resolution easy and intuitive.
Lightweight, reusable, and easy to maintain.