Hi, 

I have attached file below for you to check

  Can someone Help me understand what I'm doing wrong here? I'm currently doing Assignment 4 ScreenLifeCycle part 1, And I am stuck on part 1 of it. I managed to finish the Get room available but every time I click on Book Room to create the room the room gets created but doesn't show up in the bookings. I have set the following in my GetBookings Aggregate in the preparation for Bookings screen with "Only with" Join conditions for both Booking - Room & Booking - Status. I can see a few entries of mine which I had created recently when I changed the join condition to with or without & those entries had 0 as room number in the table. what does that mean? also, idk if I'm using the bookingId input as intended :3 Help me understand please I'm new to this, Also I want to ask how to practice more on outsystems as I feel I still lack the basic understanding of it even after following the guided path and solving those assignments.

Thanks in advance.

SyntaxEditor Code Snippet

Booking.RoomId = Room.Id

SyntaxEditor Code Snippet

Booking.StatusId = Status.Id
Solution

Hello Akii,

The entity Booking has an attribute called RoomId, right? It should have the property "Is Mandatory" set to true. This would make the tentative of saving a record into Booking entity without a valid Room Identifier, cause a validation exception. 

As you are being able to save records without this value being set, or you didn't set this property correctly, or you are not validating the form before calling the CreateOrUpdateBooking entity action.

Either way, as you are not saving the record with a valida Room Identifier, later on, in the Bookings web screen, the entity, when using a Only With (Inner Join) between the Booking and the Room entity, it will not find any match and the result will return empty.

Besides the RoomId, you must also give a correct value to the Booking.StatusId, as again, when using Only With in the aggregate, if it is not set, it will also make the aggregate return an empty list.

How to solve this?
In the GetAvailableRoom screen action, after finding the room, store the room identifier you found in the Form.Record.Booking.RoomId (it's here that this must be set). This way, when you use the Form.Record.Booking as the source to the CreateOrUpdateBooking, the ID will be there.

Remember to set also the StatusId to Booked (don't remember the correct status name right now).

This will solve this problem.

Hope the explanation was enough for you to understand what is happening.

Cheers. 

Solution

Thank You!

 That helped. I corrected a few errors like you mentioned above where, 

1. I fixed the RoomId attribute where the "Is Mandatory" was set to No  ( Changed to Yes)

2. 

SyntaxEditor Code Snippet

BookingForm.Record.Booking.RoomId

set the correct RoomId in the assign of GetAvailable Room.

3. I set 

SyntaxEditor Code Snippet

BookingForm.Record.Booking.StatusId

as StatusId in the BookRoom which was apparently set to Status.Id and assigned it to the booked attribute of Status Entity.


Now, the only problem I have is so I created a new booking with the name "James Hollywood" right and only that shows in list with all the info of it like "Room, Price, check-in, check-out, status" but then when I click on the new booking to fill that bookings page with more new bookings it shows James Hollywood info in my new form along with his details.. and if I change those and book room only "This" (By this i mean is the changed values to the new person's name and stuff) particular booking will be shown in the bookings screen.. So how do i fix this? is this happening cuz I'm not validating the form? I can show you what my book room looks like below. Also just wanted to ask do I have to change the "StatusId" Attribute to "Yes" as "Is Mandatory"? because I have. 

Also, I want to ask how do I clear the database? because since I had so many errors that I have bookings without rooms. 

Akii J wrote:

Now, the only problem I have is so I created a new booking with the name "James Hollywood" right and only that shows in list with all the info of it like "Room, Price, check-in, check-out, status" but then when I click on the new booking to fill that bookings page with more new bookings it shows James Hollywood info in my new form along with his details.. 

This happens probably because the aggregate in the preparation of the Detail page (BookingDetail) is not correct.

The aggregate must return a SINGLE record. If you pass a valid BookingId to the page (input parameter), it must find this record (than the form will start pre-filled). If you pass NullIdentifier(), it must return nothing (than the form will start empty).

This is done through a FILTER that will look in the entoity for a specific record that the ID of the record matches the ID you pass in the input parameter.

Something like: Booking.Id = BookingId.

If you are not using this filter, no matter what you pass in the input parameter, the aggregate returns ALL records in database, and the Aggreate's List.Current, that you use to feed the Form, will point to the FIRST record. So, if you don't have the filter, set it.

and if I change those and book room only "This" (By this i mean is the changed values to the new person's name and stuff) particular booking will be shown in the bookings screen.. So how do i fix this? is this happening cuz I'm not validating the form? I can show you what my book room looks like below. Also just wanted to ask do I have to change the "StatusId" Attribute to "Yes" as "Is Mandatory"? because I have. 

This happens because of the error I talked about above.

Also, I want to ask how do I clear the database? because since I had so many errors that I have bookings without rooms. 

There are easier ways, but at this point, I'll ask you to do the following:

In the Bookings page, add a new button "Delete All" to the actions area (you can remove it later) and associated it to a new Screen Action.

In the screen action, add an aggregate to fetch all bookings. Use a ForEach to iterate this aggregate list, and for each item, use the DeleteBooking entity action to delete the current record (you pass the id of the current to it).

This will delete all bookings in the database.

Cheers.


Thank you Sir!

 I didn't have a filter set so I set it now and it works as intended.