The most easy and best option is to go to your domain, to entity Berichte and tick the two checkboxes ‘createdDate’ and ‘owner’. This will automatically add the creation date and the creator as soon as the new Berichte gets initiated.
Later, when you want to show those attributes, you can just call them Berichte/createdDate and Berichte/own
If you want to still show the name of person, even after it is deleted (like Eline correctly mentions), you can also redundantly copy the Mitglied’s name to a Berichte-attribute (MitgliedName for instance). You can do this adding a AfterCreate microflow (see the tab EventHandlers in the properties of the entity) so this is done upon creation of the Berichte without you having to complicate the save-microflow.
Beware: the AfterCreate-Eventhandler for entity Berichte also get executed if you create a Berichte any other way.
And by the way: you need no ‘NewBerichte’.
Alright, so first things first – is your entity “Mitglied” a specialization of “Account”? If so, you will be able to get to it via $currentUser (with inheritance splits and casts).
I see that you're opening a page before you create your “Berichte”. I would recommend only opening the page after creating the “Berichte” (without commit) so you can pass the NewBerichte to that page and show it there, including the fields where the user can enter the message. This also means that a cancel button will actually get rid of the created object.
So your microflow for the “Create” button would look something like this:
- Cast the currentuser to get your Mitglied
- Create a new Berichte and change some attributes (e.g. the association to Mitglied, or a string with the user's username in it that stays even when an account is deleted and the currentdatetime)
- Open a page where the Berichte is shown
Here, the user can enter their data.
Now, all you need is the standard save and cancel buttons, and those should delete or commit the Berichte as needed.
Now my entity “Mitglied” is a specialization of “Account” if I did it correctly. I will have to read up on inheritance splits and casts again though since this is a pretty complicated topic at the moment in my opinion.
I did try to follow along with the instructions you gave me Eline but these are functions I have not used yet so it is taking me a little while but I think I understood the general idea of it.
At the moment my Microflow looks like this because I decided to do it from scratch and follow your steps. From my understanding, I have to insert an Object Type Decision to be able to cast anything. Now I have to read up so I figure out how to be able to cast currentuser to get my Mitglied. I hope I am not completely off topic? We have learned about this stuff already at our university lectures a little but this is going a bit deeper than our lectures.