Ajax refresh for data retrieved by a sql query and used in a container

Hello,

I am trying to build a hotel booking application.In this application there is Booking detail page.

So, for a new booking initially the "Get Available Room" button is enabled and on clicking it,a sql query is executed to display the cheapest room available,depending on the Check-in date,Check-out date,Number of adults and children and is displayed in container widget as seen above.


The "Get Available Room" action looks like below(in 2 parts):-



Get Available room sql:-



  Room Available ajax refresh for Room Available widget.


Question:-Will this scenario work for ajax refresh(clearly not working now,as it is refreshing the entire web screen instead of the widget)?

Can ajax refresh be used for queries which are calculated run time,based on parameters and assigned those values to local variable and the local variable later used to display information on the widget(Room available) or it can be used only after refreshing data in table records or list and then using ajax refreshing those widgets which are using information from the table records or list?

Please let me know if i am not clear about the question,i will try to be more clear.Added those snapshots to be as clear as possible.

Thanks in advance.

Regards,

Indranil

Hi Indranil Dey,

We can use ajax refresh after assigning values also , not required to save in database. Need to make sure we use those variable in container and fresh the container after updating local variables, it should work.

Rather than taking complex page, try with simple.

1. Create Page and have sample local variable created.

2. Show the content of local variable in web screen.

3. Create button and have on click event.

4. In that event you assign new value to variable created and refresh the container.

This is way you should be able to see newly updated value in web screen.

Let me know if I can help further.


Sravan

Hi,

The page is all refreshing because you set you button as submit and not as Ajax Submit. When you do this change it should work.

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi,

The page is all refreshing because you set you button as submit and not as Ajax Submit. When you do this change it should work.

Regards,

Marcelo


Hi Marcelo,

Thank you for your response.

I have set the method as Ajax submit only but still it refreshes the whole page it seems as all the form data are used in the sql query to retrieve the room information.

Sravan Vanteru wrote:

Hi Indranil Dey,

We can use ajax refresh after assigning values also , not required to save in database. Need to make sure we use those variable in container and fresh the container after updating local variables, it should work.

Rather than taking complex page, try with simple.

1. Create Page and have sample local variable created.

2. Show the content of local variable in web screen.

3. Create button and have on click event.

4. In that event you assign new value to variable created and refresh the container.

This is way you should be able to see newly updated value in web screen.

Let me know if I can help further.


Sravan

Hi Sravan,

Thanks for your response.With simple page it works but in my case,its not working as expected.Any other suggestions to move ahead.


Hi Indranil,

Can you share your solution so I can look into it.

Regards,

Marcelo

Hello All,

Right now with above mentioned flow and using Ajax Submit method,


the room/price information  and the book room buttons are not appearing which is happening while making the method as submit.

The entire flow:-

The query information and the assignments are posted previously

Hello Indranil,

Sorry, but it is really hard to understand what's the problem you are facing.
What Marcelo asked was for your OML so that we can take a look directly.

Open your module, go to menu Module and export it to a file, than attach in a message here:

Cheers.

Hello Marcelo/Eduardo,

Thanks for your responses.

Please find the oml file attached.

Regards,

Indranil

Marcelo Ferreira wrote:

Hi Indranil,

Can you share your solution so I can look into it.

Regards,

Marcelo

Hi Marcelo,

I have attached the .oml here.

Can you have a look and let me know?

Regards,

Indranil


Eduardo Jauch wrote:

Hello Indranil,

Sorry, but it is really hard to understand what's the problem you are facing.
What Marcelo asked was for your OML so that we can take a look directly.

Open your module, go to menu Module and export it to a file, than attach in a message here:

Cheers.


Hi Eduardo,

I have attached the .oml here.

Can you have a look and let me know?

Regards,

Indranil

Hello Indranil,

Some things to point out.

1. The CanceledStatus query parameter in the GetAvailableRoom SQL tool has the wrong data type. If you are comparing it to {Booking}.[StatusId], its data type can't be "Boolean". It has to be a Status Identifier (and you will pass to the SQL tool Entities.Status.Cancelled as the value).

2. After this, you are saving the result of the SQL tool into a local variable (AvailableRoom). This is not the best way to do this, as this will create problems when you want to see an existing booking. The better would be to store the GetAvailableRoom.List.Current.Room.Id in the attribute RoomId of the Booking in the Form record (as you need it there in order to save the booking), and the RoomNumber and Price in the respective attributes of the Room entity in the Form record, making the change in the expression in the form to get from there the Room Number and Price.

3. After those changes, the only thing I think is missing is to remove the assignments for Room and RoomId in the Book screen action, keeping only the status.

This probably will solve the issue (as I can't see anything else wrong, at this moment).

Hope this helps.

Cheers.