Implementing generic action to change status of bookings in booking assignment

Implementing generic action to change status of bookings in booking assignment

  

Hi,

i am working on booking assignment's part 6, in which we have to change the bookings status by using button clicks for existing bookings, i.e if checkedIn then perform checkout, if booked then perform check in or cancel booking.

I didn't get how to perform this by changing onlyone attribute from the database table.

Is there anyone  to help

thanks

Hi,

You can do the following:

Get the record you want to change status from database. You can do this with an aggregate or sql, using a filter for the id. Or get the record using the entity action Get or GetForUpdate (entity actions are under the Entity in the Data layer.

Than you can use an assign to change only the field you want to change, and than use a Update entity action passing this record.

So, what you need is to get the record, change the status, and save the record back to database.

Use a Server Action that will receive the record id and the new status as input parameters.

Cheers

Eduardo Jauch


hi Eduardo,

I have attached screen shot of how i used your logic, but i didnt understand where to use that server action and how to pass that status into? 

Best regards

Hi,

In the assign, you will have to UPDATE the record returned by the GetBookingForUpdate action with the value you must provide as input parameter.

So:

1. You need an InputParameter that is of type status identifier.

2. In the assign, you will change the GetBookingForUpdate.Record (field statusId or the name you gave to it.) with the value of the Input parameter. DON'T use anything from the form here, because this should be a SERVER action, not a SCREEN action (so you can call it from anywhere in the application).

3. You will provide the GetBookingForUpdate.Record to the UpdateBooking action

Just this :)

Cheers,
Eduardo Jauch

hi edurado,

i didnt got your point, can you please tell me the steps to perform.and Note:"i have used checked in,checked out and cancell booking  buttons to change the status.

I'll shall be very thankful to you men.

Kind Regards

When i Click the button of check-in, the customer checked in and status in the bookings table change to checked-In.

Sorry for my little knowledge about outsystem :)

Thanks

Hello Usama,

You are studying. This is good :)

Can you send me your OML so I can take a look? (Go to Module, click in Export and than in Save As), than attach it in an answer here in the forum.

In any case:

1. Create a Server Action called ChangeStatus (name is just an example).

2. Inside it, add an Input Parameter named BookingId (type, Booking Identifier), and another called BookingStatusId (BookingStatus Identifier), note that I don't know what you called this static entity, that is the static entity that have the possible statuses of a booking). This second parameter will be the status that you want to apply to the Booking referenced by the Id.

3. Place a Node GetBookingForUpdate, passing the id as input for it.

4. Add an Assign node and on it, assign the Status (passed as input parameter) to the STATUS field in the record returned by the GetBookingForUpdate (it will be available for selection in the assignment)

5. Place a note UpdateBooking after the assignment node and give the GetBookingForUpdate record as input to it.

Now you are ready to use this action on any Screen Action so you can change the status of a booking record (just call the action and pass the ID and the new status).

Cheers,
Eduardo Jauch

Hi,

this is the oml of my module, how can that function know that the checked in button is pressed?

Hi Usama,

You have to call a ScreenAction when clicking the button, and the screen action will call the function. :)

Usama, you can't call ChangeStatus from inside it. You are creating a recursive function that will enter an infinite looping. 

And you will be unable to stop the application for at least 20 min... 

Eduardo Jauch wrote:

Hi Usama,

You have to call a ScreenAction when clicking the button, and the screen action will call the function. :)


thankyou so much for your time,let me try this and i'll let you know the results

:)

Sorry, didn't noticed that you were calling the action from the screen action.
See the attached file to see how I did :) (Only CheckIn is using, for now).

hi,

thanks eduardo but thats not working...i have created the same as you have created now but status is not changing.

I have attached the OML along

thanks

Solution

hi that worked now :)

but i want to use only one action to perform all the three task .i.e. CheckedIn, CheckOut, Cancel booking.


Solution