You can use the function isNew(object) in a split. If true, delete the relation and activity object, if false close the form.
Hi Frans,
In addition to Jaap's answer, you can delete an association by changing the object in a microflow and set the first association with the value 'empty'.
Furthermore:
I have added an invoke button to the predecessor grid that should open an activity form and set the relation between the context activity and the new activity. For that I have created a microflow that creates the new activity, creates the new relation, sets the successor to the context activity, set the predecessor to the new activity and opens the activity form on the new activity
This action above, you should not perform a commit. However, you have to refresh in client. Then you should show a form with the new activity, new relation, successor and predecessor and standard save and cancel buttons. This form (dataview) shows the associations while they are not committed to the database yet. If the user clicks on the save button, automatically both the object and associations will be set. If the user presses the cancel button, automatically all the actions will be rolled back (and cancelled).
In case you show the associations in a nested grid within a dataview, you have to commit them first. You can use a customized cancel button to remove / delete the associations.
You can also model two different forms. Disadvantage of that solution is double maintenance.