Regarding navigating from one screen to another

Hello Team,

Actually, I'm developing mobile app. and stuck on one thing like when I'm navigating from one screen which consist of Form, I'm filling all the details-

But when I'm navigating to new screen -

and when again I get back to the previous screen where I filled all the details, then it shows all fields are empty and the data i have entered get vanished -


Could anyone please help me that how to persist the details entered in form screen if, navigating to another screen and entered data should not get vanish when again navigate to form screen?

I'll be grateful to you.

Also, I'm attaching OML file of the app. for your convenience.

Will wait for your kind revert.

Best Regards,

Rohit Jaswani

Hi Ronit,


The thing is your comboboxes don't have a special value for when the variable is empty / you haven't selected anything, so even if the variable bounded to them is null, they will appear.


Try defining an empty value on the combo boxes, like this:



Cheers,

João

Hi Rohit,

You have to pass "BookingDetailsId" as well as highlighted in below snapshot.

As In your "BookingDetail" screen you are fetching data for age, address, DOB.....so on from "GetBookingDetails2" aggregate where you use a filter using "BookingDetailsId" as you are not passing any values from "BackOnClick" action rest of the fields are empty when to navigate to your detail screen ("BookingDetailsId" is consider null identifier).

Hope this will help you 

Regards,

Vipasa

Hey guys,

I didn't look the .oml yet.


But just giving a quick look seems like the data from form is bound to an aggregate is that right?


Every time you change screen and go back this aggregate will run again, so before going to the other screen, if you want to persist data, you have to save it.


This way when you go back to the previous screen, the aggregate will return the values saved.


Are you saving the data?


Hi Rohit,


This is normal behavior for any app/web page i.e. loosing data or loosing state of the page. There are 2 approach you can follow to maintain state of the page. 

1. If you are navigating to other screen without saving your data, you will have to store values in some variable, like client variable. So instead of binding variable to aggregate, you have to bind with client variable( You can assign these client variable's data again to aggregate in save button action)

2. If you are navigating after saving data, then you can use BookingDetailId to again retrieve saved data to your page( like Vipasha mentioned).


Hope it helps!

Thanks,

Sanjay

Sanjay Kumar Sahu wrote:

Hi Rohit,


This is normal behavior for any app/web page i.e. loosing data or loosing state of the page. There are 2 approach you can follow to maintain state of the page. 

1. If you are navigating to other screen without saving your data, you will have to store values in some variable, like client variable. So instead of binding variable to aggregate, you have to bind with client variable( You can assign these client variable's data again to aggregate in save button action)

2. If you are navigating after saving data, then you can use BookingDetailId to again retrieve saved data to your page( like Vipasha mentioned).


Hope it helps!

Thanks,

Sanjay

 Hello Sanjay,

Thanks for your kind revert and valuable advice. 

I followed the advice given by you to store data in Client Variable to persist the data. For testing purpose, I only used  Data of Age Variable to store it to Client Variable - Age.

To save the data to Client Variable, I have assigned the Variable in which data is getting fetch from aggregate, then navigating to another screen, as shown in below picture -

Further, if I navigate to previous screen and data of age which i have entered earlier should not get vanish, i have created the logic on OnDestroy Event, as shown in below picture-

But still, when I navigate to previous screen, the data of Age entered by me get vanish. 

Could you please help me that where I'm lacking and what should be done to get this thing done.Will be very grateful to you.

For your convenience I'm also attaching the OML file.

Will wait for your kind revert.

Best Regards,

Rohit Jaswani

Raphael Ranieri wrote:

Hey guys,

I didn't look the .oml yet.


But just giving a quick look seems like the data from form is bound to an aggregate is that right?


Every time you change screen and go back this aggregate will run again, so before going to the other screen, if you want to persist data, you have to save it.


This way when you go back to the previous screen, the aggregate will return the values saved.


Are you saving the data?


 

 Hello Raphael,

Thanks for your kind revert.

Yes, the data in form bound to an aggregate.

Yes, now after getting the advice from @Sanjay I tried to save the data to Client Variable  and again when I get back to previous screen I'm trying to fetch data from Client Variable. 

But, still, somewhere I'm lacking to execute this thing successfully.

I have shared what I have done while replying to Sanjay. Could you please have a look and suggest me what should be done to successfully implement such functionality. 

Your advice and efforts will be appreciated.

Will wait for your kind revert.

Best Regards,

Rohit Jaswani.

Vipasha Sharma wrote:

Hi Rohit,

You have to pass "BookingDetailsId" as well as highlighted in below snapshot.

As In your "BookingDetail" screen you are fetching data for age, address, DOB.....so on from "GetBookingDetails2" aggregate where you use a filter using "BookingDetailsId" as you are not passing any values from "BackOnClick" action rest of the fields are empty when to navigate to your detail screen ("BookingDetailsId" is consider null identifier).

Hope this will help you 

Regards,

Vipasa

 Hello Vipasha,

Thanks for your kind revert.

I followed what you conveyed to me.

But still, I'm unable to execute what i want to do.

I elaborated like what i have done while replying to Sanjay. Could you please have a look and could you please suggest me like what should be done further to get the thing done.

Your efforts and suggestions will be appreciated.

Will wait for your kind revert.

Best Regards,

Rohit Jaswani

 

Solution

Hello,


Rohit I took a look in the .oml

To use the Client Variable approach you would have to assign the Value of Age saved in the client variable in the OnAfterFecth of your aggregate, something like this:



However I really think this is not the best approach you can use.

What you should do is instead of saving the values in client variables, is saving them in your entity record, so before navigating to the new screen you would save it in the DB, something like this:


If you can't save it directly to DB because it would persist the data and this way confirm the booking, you should use an offline approach.

Saving it offline in the local storage, and after the confirmation, commiting to server.


Keep in mind that client variables are something like sessions variable, so in the client variables approach even if you access a different book record (With a different ID) it would fill the age, because this variable is shared for all the application and is not binded with a specific booking ID.


If you don't want to use neither of this solutions (Client Variables, Local Storage or Commiting to server before confirming) what you can do is to put the content of the terms page in a webblock, and use it in the same screen, toggling a bool var.

Something like ShowTerms. If true you only show the block, if false you show everything else.

This way you would not need to change the page, and would not lose the data filled. Also you could persist the data only when confirmed :)


Cheers and Regards,

RR

Solution

Hello Rohit,


I have seen your OML but unfortunately your implementation is not what I was suggesting you and its my fault I didn't elaborate properly. Let me explain you briefly for same client variable. 

Actually you should store input in client.age like below :

  

and in Save button action you can retrieve client.age value and assign it to aggregate like below :

Like this you could do for all user input and this will surely persist your data, no doubt.

But this approach is only useful for New bookings as first time you don't have these value saved in your DB.

In case of edit, you will be having this data in DB so just need to retrieve by using BookingDetailId. 

Hope it helps!

Thanks,

Sanjay

And also, I have another suggestions for your concern and probably it will solve your issue in best way.

You are using Terms&Condition screen just to display some text message, so there is no need to fetch data through aggregate as you are not using it. Second, there is absolutely no use of this extra screen, you can just use Pop-up to display Terms&Condition like below:

1. Take a container at very bottom of page

2. Define a bool var like below:

3. Map pop-up to that var :

4. Inside that pop-up, take another container and copy paste your text content.

5. On LinkOnClick action, change the Boolean value to display pop-up :

6. Inside the pop-up, create a button which will also fire a similar client action but this time it should change the value of Showpopup to false, to close the pop-up.


Let me know if it suits your requirement or you still want to approach as your first option.


Thanks,

Sanjay

Hi Sanjay,

Indeed this way, from the first post, can work to edit the client variables, but how you said he would never be able to edit a specific record without further logic (Defining the client variables in the after fetch action of an aggregate returning the data of an existing record for example), that would not be easily understandable by others.

The pattern that are even created by scaffolding in OutSystems is to bind the forms with aggregates and not with client variables.

Another problem is that the client variable would have always the same values, so every time the user accessed this screen, from anywhere he would see the same value (If the clients variables were not changed in after fetch of the aggregate or if they were not cleaned with extra logic)

So, in my opinion this would not be a best practice and would not provide an easy maintainability.


Cheers and Regards,

RR :)

Rohit,


For more information on How to use forms in Reactive Web take a look here


For know when a Client Variable should be used take a look here.


There are some common usage scenarios:


Cheers

Rohit Jaswani wrote:

Vipasha Sharma wrote:

Hi Rohit,

You have to pass "BookingDetailsId" as well as highlighted in below snapshot.

As In your "BookingDetail" screen you are fetching data for age, address, DOB.....so on from "GetBookingDetails2" aggregate where you use a filter using "BookingDetailsId" as you are not passing any values from "BackOnClick" action rest of the fields are empty when to navigate to your detail screen ("BookingDetailsId" is consider null identifier).

Hope this will help you 

Regards,

Vipasa

 Hello Vipasha,

Thanks for your kind revert.

I followed what you conveyed to me.

But still, I'm unable to execute what i want to do.

I elaborated like what i have done while replying to Sanjay. Could you please have a look and could you please suggest me like what should be done further to get the thing done.

Your efforts and suggestions will be appreciated.

Will wait for your kind revert.

Best Regards,

Rohit Jaswani

 

 

 Hi Rohit,

I did some changes in your OML, Following are the list where I made changes

1. OnInitialize (Booking Detail screen)

2. GetLocalBookingDetailsByID (aggregate in Booking detail screen)

**Suggestions

- You can use Modal to open the "Terms & Condition" screen

As you bind all the fields (in form) of "Booking Detail Screen" with "GetBookingDetails2" aggregate and on the click of "Terms & condition" you are saving values inside "Local Booking DEtails" that why all the fields are empty when you came back to previous screen.

So you need to assign all values of "Local Booking" entity to the "Booking entity" in "OnInitialize"  of the screen.(I did all the changes into attached OML)

Hope this will work for you.

Regards,

Vipasha

Raphael Ranieri wrote:

Hello,


Rohit I took a look in the .oml

To use the Client Variable approach you would have to assign the Value of Age saved in the client variable in the OnAfterFecth of your aggregate, something like this:



However I really think this is not the best approach you can use.

What you should do is instead of saving the values in client variables, is saving them in your entity record, so before navigating to the new screen you would save it in the DB, something like this:


If you can't save it directly to DB because it would persist the data and this way confirm the booking, you should use an offline approach.

Saving it offline in the local storage, and after the confirmation, commiting to server.


Keep in mind that client variables are something like sessions variable, so in the client variables approach even if you access a different book record (With a different ID) it would fill the age, because this variable is shared for all the application and is not binded with a specific booking ID.


If you don't want to use neither of this solutions (Client Variables, Local Storage or Commiting to server before confirming) what you can do is to put the content of the terms page in a webblock, and use it in the same screen, toggling a bool var.

Something like ShowTerms. If true you only show the block, if false you show everything else.

This way you would not need to change the page, and would not lose the data filled. Also you could persist the data only when confirmed :)


Cheers and Regards,

RR

 Thank you so much Raphael for your kind revert and valuable advice.

I tried to get the things done on OnAfterFetch and in your next reply you have suggested to clear values from client variables when the values get fetch from Client Variables.

Now, everything is running great as wanted. Your suggestions helped me.

Thank you so much for your co-operation.

Best Regards,

Rohit Jaswani 

Cheers :)

Sanjay Kumar Sahu wrote:

And also, I have another suggestions for your concern and probably it will solve your issue in best way.

You are using Terms&Condition screen just to display some text message, so there is no need to fetch data through aggregate as you are not using it. Second, there is absolutely no use of this extra screen, you can just use Pop-up to display Terms&Condition like below:

1. Take a container at very bottom of page

2. Define a bool var like below:

3. Map pop-up to that var :

4. Inside that pop-up, take another container and copy paste your text content.

5. On LinkOnClick action, change the Boolean value to display pop-up :

6. Inside the pop-up, create a button which will also fire a similar client action but this time it should change the value of Showpopup to false, to close the pop-up.


Let me know if it suits your requirement or you still want to approach as your first option.


Thanks,

Sanjay

Thank you so much Sanjay for your kind revert and valuable advice.

Indeed, you are the one who has initially given me advice for client variables or I say to get this thing done. 

Also, I Thank you for letting me know about the widget Pop-up  and you elaborately explained me everything.

I'm sure, working of this Pop-up widget will definitely help me in future. As of now,  what I wanted, successfully done through the use of Client Variables.

Once again Thank you for your co-operation.

Best Regards,

Rohit Jaswani


 

Vipasha Sharma wrote:

Rohit Jaswani wrote:

Vipasha Sharma wrote:

Hi Rohit,

You have to pass "BookingDetailsId" as well as highlighted in below snapshot.

As In your "BookingDetail" screen you are fetching data for age, address, DOB.....so on from "GetBookingDetails2" aggregate where you use a filter using "BookingDetailsId" as you are not passing any values from "BackOnClick" action rest of the fields are empty when to navigate to your detail screen ("BookingDetailsId" is consider null identifier).

Hope this will help you 

Regards,

Vipasa

 Hello Vipasha,

Thanks for your kind revert.

I followed what you conveyed to me.

But still, I'm unable to execute what i want to do.

I elaborated like what i have done while replying to Sanjay. Could you please have a look and could you please suggest me like what should be done further to get the thing done.

Your efforts and suggestions will be appreciated.

Will wait for your kind revert.

Best Regards,

Rohit Jaswani

 

 

 Hi Rohit,

I did some changes in your OML, Following are the list where I made changes

1. OnInitialize (Booking Detail screen)

2. GetLocalBookingDetailsByID (aggregate in Booking detail screen)

**Suggestions

- You can use Modal to open the "Terms & Condition" screen

As you bind all the fields (in form) of "Booking Detail Screen" with "GetBookingDetails2" aggregate and on the click of "Terms & condition" you are saving values inside "Local Booking DEtails" that why all the fields are empty when you came back to previous screen.

So you need to assign all values of "Local Booking" entity to the "Booking entity" in "OnInitialize"  of the screen.(I did all the changes into attached OML)

Hope this will work for you.

Regards,

Vipasha

 Thank you so much Vipasha for your kind revert and valuable advice.

I have successfully done, what I wanted, by storing the data of input fields to the client variables before moving to another screen and fetching the data from those client variables to the input fields while returning to that form screen.

Thank you so much for your co-operation.

Best Regards,

Rohit Jaswani


 

Rohit Jaswani wrote:

Sanjay Kumar Sahu wrote:

And also, I have another suggestions for your concern and probably it will solve your issue in best way.

You are using Terms&Condition screen just to display some text message, so there is no need to fetch data through aggregate as you are not using it. Second, there is absolutely no use of this extra screen, you can just use Pop-up to display Terms&Condition like below:

1. Take a container at very bottom of page

2. Define a bool var like below:

3. Map pop-up to that var :

4. Inside that pop-up, take another container and copy paste your text content.

5. On LinkOnClick action, change the Boolean value to display pop-up :

6. Inside the pop-up, create a button which will also fire a similar client action but this time it should change the value of Showpopup to false, to close the pop-up.


Let me know if it suits your requirement or you still want to approach as your first option.


Thanks,

Sanjay

Thank you so much Sanjay for your kind revert and valuable advice.

Indeed, you are the one who has initially given me advice for client variables or I say to get this thing done. 

Also, I Thank you for letting me know about the widget Pop-up  and you elaborately explained me everything.

I'm sure, working of this Pop-up widget will definitely help me in future. As of now,  what I wanted, successfully done through the use of Client Variables.

Once again Thank you for your co-operation.

Best Regards,

Rohit Jaswani


 

 You're Welcome!