Delete of relation committed in microflow after cancel

3
Activity has 2 (predecessor and successor) 0-1 relations with ActivityRelation. I have a form with the 2 datagrids of relations. 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. I had to commit the relation to make this work. The issue is that when I cancel the form on the new activity, the relation has to be deleted again to prevent orphan records in the database. So I needed to create manual save and cancel buttons. The cancel button should check whether the new activity already existed. If so, it should just close the form. If not, it should delete the relation object and close the form. I wanted to do this by checking the existence of the new activity in the database. However, it turns out that the new activity is also committed when I commit the relation. The questions: Is there a way to commit the relation without committing the new activity? If not, is there another way to check whether the relation should be deleted on cancel? I hope my question is clear...
asked
2 answers
3

You can use the function isNew(object) in a split. If true, delete the relation and activity object, if false close the form.

answered
3

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.

answered