Updating record of an entity

0
Hi everyone, I’m making a guestbook with Mendix and I encountered a problem. I found a solution but I wanted to know if there was a more direct approach to it. Basically I want to track every guest that visits a place, recording every entrance and every exit, both should happen the same day. When the guest have to check their exit, the guestbook should retrieve the record from the database. After retrieving the record from the database, the exit date and time will be recorded. The problem lies here: how do I update the record without creating a new object? How do I make it edit the last record and not the first one? I hope I was clear enough.
asked
2 answers
0

Hi Luca,

Perhaps you can retrieve the record of that person with the latest start date (so select first in the xpath and sort on start date descending). Does this answer your question?

 

answered
0

Dear Luca,

The solution depends on your business need. Let see the possibilities

  1. If you would like a complete track of the guest including what days he visited, when he entered when he existed, you definitely need two entities a) Guest b) VisitRecord with one to many association. In this case, every transaction would have a transaction type Entry, Exit, Visit to certain spots etc with datetime stamp
  2. If you just want to capture the entry and exit of a guest, you can have two attrbutes entryDateTime exitDateTime and to update the record, you need to fetch it by the Guest id or name and based on the max(EntryDate) with ExitDate empty  This could be achieved either in one step by downloading the entire transaction of the guest and sorting in the descending order and updating the first record  or by fetching the record with max(EntryDate) and updating the same.
answered