Hi,

I have a transition from screen A to screen B in my app.

In screen A, I am doing some array operation in onInit() action like adding elements to array and then after an event occurs navigating to screen B.

On screen B's 'Back' button(top left corner), I run this code $public.Navigation.navigateBack(0); 

Once the app is navigated to screen A, the state of array is reinitialized and I am loosing the data I have added to the array. To get rid of this, I added registerBackNavigationHandler() to screen so that I can handle the state of array in screen A when 'Back' button is pressed from screen B. But somehow, the callback method mentioned in the handler is not getting invoked.

Can anyone please help me in this regards.

Thanks,

Shreyas Bhondve

Shreyas Bhondve wrote:

Hi,

I have a transition from screen A to screen B in my app.

In screen A, I am doing some array operation in onInit() action like adding elements to array and then after an event occurs navigating to screen B.

On screen B's 'Back' button(top left corner), I run this code $public.Navigation.navigateBack(0); 

Once the app is navigated to screen A, the state of array is initialized and I am loosing the data I have added to the array. To get rid of this, I added registerBackNavigationHandler() to screen so that I can handle the state of array in screen A when 'Back' button is pressed from screen B. But somehow, the callback method mentioned in the handler is not getting invoked.

Can anyone please help me in this regards.

Thanks,

Shreyas Bhondve


Hello Shreyas,


Can you share the code where you call registerBackNavigationHandler? Also the code of the callback function itself.

Thanks!

Jay Santos wrote:

Shreyas Bhondve wrote:

Hi,

I have a transition from screen A to screen B in my app.

In screen A, I am doing some array operation in onInit() action like adding elements to array and then after an event occurs navigating to screen B.

On screen B's 'Back' button(top left corner), I run this code $public.Navigation.navigateBack(0); 

Once the app is navigated to screen A, the state of array is initialized and I am loosing the data I have added to the array. To get rid of this, I added registerBackNavigationHandler() to screen so that I can handle the state of array in screen A when 'Back' button is pressed from screen B. But somehow, the callback method mentioned in the handler is not getting invoked.

Can anyone please help me in this regards.

Thanks,

Shreyas Bhondve


Hello Shreyas,


Can you share the code where you call registerBackNavigationHandler? Also the code of the callback function itself.

Thanks!

You mean the .oml file?


Shreyas Bhondve wrote:

Jay Santos wrote:

Shreyas Bhondve wrote:

Hi,

I have a transition from screen A to screen B in my app.

In screen A, I am doing some array operation in onInit() action like adding elements to array and then after an event occurs navigating to screen B.

On screen B's 'Back' button(top left corner), I run this code $public.Navigation.navigateBack(0); 

Once the app is navigated to screen A, the state of array is initialized and I am loosing the data I have added to the array. To get rid of this, I added registerBackNavigationHandler() to screen so that I can handle the state of array in screen A when 'Back' button is pressed from screen B. But somehow, the callback method mentioned in the handler is not getting invoked.

Can anyone please help me in this regards.

Thanks,

Shreyas Bhondve


Hello Shreyas,


Can you share the code where you call registerBackNavigationHandler? Also the code of the callback function itself.

Thanks!

You mean the .oml file?


If you can share the .oml is even better


Jay Santos wrote:

Shreyas Bhondve wrote:

Jay Santos wrote:

Shreyas Bhondve wrote:

Hi,

I have a transition from screen A to screen B in my app.

In screen A, I am doing some array operation in onInit() action like adding elements to array and then after an event occurs navigating to screen B.

On screen B's 'Back' button(top left corner), I run this code $public.Navigation.navigateBack(0); 

Once the app is navigated to screen A, the state of array is initialized and I am loosing the data I have added to the array. To get rid of this, I added registerBackNavigationHandler() to screen so that I can handle the state of array in screen A when 'Back' button is pressed from screen B. But somehow, the callback method mentioned in the handler is not getting invoked.

Can anyone please help me in this regards.

Thanks,

Shreyas Bhondve


Hello Shreyas,


Can you share the code where you call registerBackNavigationHandler? Also the code of the callback function itself.

Thanks!

You mean the .oml file?


If you can share the .oml is even better




Thaks Shreyas, can you point me to the screens A and B you've mentioned? Lots of screens on the .oml :)

Jay Santos wrote:

Thaks Shreyas, can you point me to the screens A and B you've mentioned? Lots of screens on the .oml :)


I knew it will be confusing, so I confirmed whether to share complete oml file :)

SearchHospital (screen A)
MyCalendar (screen B)

I did a simple demo trying to do the same without success. I'll check it internally and get back to you.

Hi Shreyas Bhondv,

A friendly reminder to you regarding the OML you uploaded. You might be associated with an enterprise Company for the Product. Thus uploading a complete Mobile App [Product] is not a good practice from a security & confidentiality point of view. I would suggest you remove it instantly as of it may land your company in trouble with NDA Clauses if it's a Product & not your own Practice app.


Perhaps coming to your issue,

I went through the OML & I would suggest the below approach:

No matter you use JS, you are going to lose the Screen State as of every time the Screen render from a BackStack in Mobile app, it is going to re-start its lifecycle Initially i.e onInitialize

Well, your only requirement is to maintain a state of the Array that you are keeping Append by some data.

So when you navigate from SearchHospitalScreen to MyCalendar, Pass a YourArrayType Param to MyCalendar Screen & Get it back when you come from MyCalendar to SearchHospitalScreen.

1-Declare SearchHospitalScreen with an InputVariable of YourArrayType let's say MyArray 

2-Declare MyCalendar with an InputVariable of YourArrayType let's say MyArrayData

3-While you Navigate back to SearchHospitalScreen again pass the MyArrayData as an Input to it.

This way you can maintain the state of the Array via Rotating it between screens & yes the navigation can be kept normal instead of any JS. Once you get back the Array then under onInitialze you can re-use it in & pass it to PlotHospitalonMap Action.

Do let me know if you need more help for the same. I'll try to Implement this on your OML.

Hope it helps,

Assif



assif_tiger wrote:

Hi Shreyas Bhondv,

A friendly reminder to you regarding the OML you uploaded. You might be associated with an enterprise Company for the Product. Thus uploading a complete Mobile App [Product] is not a good practice from a security & confidentiality point of view. I would suggest you remove it instantly as of it may land your company in trouble with NDA Clauses if it's a Product & not your own Practice app.


Perhaps coming to your issue,

I went through the OML & I would suggest the below approach:

No matter you use JS, you are going to lose the Screen State as of every time the Screen render from a BackStack in Mobile app, it is going to re-start its lifecycle Initially i.e onInitialize

Well, your only requirement is to maintain a state of the Array that you are keeping Append by some data.

So when you navigate from SearchHospitalScreen to MyCalendar, Pass a YourArrayType Param to MyCalendar Screen & Get it back when you come from MyCalendar to SearchHospitalScreen.

1-Declare SearchHospitalScreen with an InputVariable of YourArrayType let's say MyArray 

2-Declare MyCalendar with an InputVariable of YourArrayType let's say MyArrayData

3-While you Navigate back to SearchHospitalScreen again pass the MyArrayData as an Input to it.

This way you can maintain the state of the Array via Rotating it between screens & yes the navigation can be kept normal instead of any JS. Once you get back the Array then under onInitialze you can re-use it in & pass it to PlotHospitalonMap Action.

Do let me know if you need more help for the same. I'll try to Implement this on your OML.

Hope it helps,

Assif



Hi Assif,

I will try this approach.

Also, could you please let me know how do I remove the OML file uploaded?

Regards,

Shreyas Bhondve


Shreyas Bhondve wrote:

assif_tiger wrote:

Hi Shreyas Bhondv,

A friendly reminder to you regarding the OML you uploaded. You might be associated with an enterprise Company for the Product. Thus uploading a complete Mobile App [Product] is not a good practice from a security & confidentiality point of view. I would suggest you remove it instantly as of it may land your company in trouble with NDA Clauses if it's a Product & not your own Practice app.


Perhaps coming to your issue,

I went through the OML & I would suggest the below approach:

No matter you use JS, you are going to lose the Screen State as of every time the Screen render from a BackStack in Mobile app, it is going to re-start its lifecycle Initially i.e onInitialize

Well, your only requirement is to maintain a state of the Array that you are keeping Append by some data.

So when you navigate from SearchHospitalScreen to MyCalendar, Pass a YourArrayType Param to MyCalendar Screen & Get it back when you come from MyCalendar to SearchHospitalScreen.

1-Declare SearchHospitalScreen with an InputVariable of YourArrayType let's say MyArray 

2-Declare MyCalendar with an InputVariable of YourArrayType let's say MyArrayData

3-While you Navigate back to SearchHospitalScreen again pass the MyArrayData as an Input to it.

This way you can maintain the state of the Array via Rotating it between screens & yes the navigation can be kept normal instead of any JS. Once you get back the Array then under onInitialze you can re-use it in & pass it to PlotHospitalonMap Action.

Do let me know if you need more help for the same. I'll try to Implement this on your OML.

Hope it helps,

Assif



Hi Assif,

I will try this approach.

Also, could you please let me know how do I remove the OML file uploaded?

Regards,

Shreyas Bhondve


Hello Shreyas ,

You might see a Delete option there on the bottom-left of your comment [next to - reply button ] or If it doesn't show I would suggest to delete the Post & post a new question for same.

- Assif


assif_tiger wrote:

Hi Shreyas Bhondv,

A friendly reminder to you regarding the OML you uploaded. You might be associated with an enterprise Company for the Product. Thus uploading a complete Mobile App [Product] is not a good practice from a security & confidentiality point of view. I would suggest you remove it instantly as of it may land your company in trouble with NDA Clauses if it's a Product & not your own Practice app.


Perhaps coming to your issue,

I went through the OML & I would suggest the below approach:

No matter you use JS, you are going to lose the Screen State as of every time the Screen render from a BackStack in Mobile app, it is going to re-start its lifecycle Initially i.e onInitialize

Well, your only requirement is to maintain a state of the Array that you are keeping Append by some data.

So when you navigate from SearchHospitalScreen to MyCalendar, Pass a YourArrayType Param to MyCalendar Screen & Get it back when you come from MyCalendar to SearchHospitalScreen.

1-Declare SearchHospitalScreen with an InputVariable of YourArrayType let's say MyArray 

2-Declare MyCalendar with an InputVariable of YourArrayType let's say MyArrayData

3-While you Navigate back to SearchHospitalScreen again pass the MyArrayData as an Input to it.

This way you can maintain the state of the Array via Rotating it between screens & yes the navigation can be kept normal instead of any JS. Once you get back the Array then under onInitialze you can re-use it in & pass it to PlotHospitalonMap Action.

Do let me know if you need more help for the same. I'll try to Implement this on your OML.

Hope it helps,

Assif




Hi Assif,

How do I pass the array while navigating back to the previous screen?

Regards,

Shreyas Bhondve

Shreyas Bhondve wrote:

assif_tiger wrote:

Hi Shreyas Bhondv,

A friendly reminder to you regarding the OML you uploaded. You might be associated with an enterprise Company for the Product. Thus uploading a complete Mobile App [Product] is not a good practice from a security & confidentiality point of view. I would suggest you remove it instantly as of it may land your company in trouble with NDA Clauses if it's a Product & not your own Practice app.


Perhaps coming to your issue,

I went through the OML & I would suggest the below approach:

No matter you use JS, you are going to lose the Screen State as of every time the Screen render from a BackStack in Mobile app, it is going to re-start its lifecycle Initially i.e onInitialize

Well, your only requirement is to maintain a state of the Array that you are keeping Append by some data.

So when you navigate from SearchHospitalScreen to MyCalendar, Pass a YourArrayType Param to MyCalendar Screen & Get it back when you come from MyCalendar to SearchHospitalScreen.

1-Declare SearchHospitalScreen with an InputVariable of YourArrayType let's say MyArray 

2-Declare MyCalendar with an InputVariable of YourArrayType let's say MyArrayData

3-While you Navigate back to SearchHospitalScreen again pass the MyArrayData as an Input to it.

This way you can maintain the state of the Array via Rotating it between screens & yes the navigation can be kept normal instead of any JS. Once you get back the Array then under onInitialze you can re-use it in & pass it to PlotHospitalonMap Action.

Do let me know if you need more help for the same. I'll try to Implement this on your OML.

Hope it helps,

Assif




Hi Assif,

How do I pass the array while navigating back to the previous screen?

Regards,

Shreyas Bhondve

Moreover, why can't I make use registerBackNavigationHandler in SearchHosital screen which is supposed to be invoked when navigating back from MyCalendar?


Solution

Shreyas Bhondve wrote:

Shreyas Bhondve wrote:

assif_tiger wrote:

Hi Shreyas Bhondv,

A friendly reminder to you regarding the OML you uploaded. You might be associated with an enterprise Company for the Product. Thus uploading a complete Mobile App [Product] is not a good practice from a security & confidentiality point of view. I would suggest you remove it instantly as of it may land your company in trouble with NDA Clauses if it's a Product & not your own Practice app.


Perhaps coming to your issue,

I went through the OML & I would suggest the below approach:

No matter you use JS, you are going to lose the Screen State as of every time the Screen render from a BackStack in Mobile app, it is going to re-start its lifecycle Initially i.e onInitialize

Well, your only requirement is to maintain a state of the Array that you are keeping Append by some data.

So when you navigate from SearchHospitalScreen to MyCalendar, Pass a YourArrayType Param to MyCalendar Screen & Get it back when you come from MyCalendar to SearchHospitalScreen.

1-Declare SearchHospitalScreen with an InputVariable of YourArrayType let's say MyArray 

2-Declare MyCalendar with an InputVariable of YourArrayType let's say MyArrayData

3-While you Navigate back to SearchHospitalScreen again pass the MyArrayData as an Input to it.

This way you can maintain the state of the Array via Rotating it between screens & yes the navigation can be kept normal instead of any JS. Once you get back the Array then under onInitialze you can re-use it in & pass it to PlotHospitalonMap Action.

Do let me know if you need more help for the same. I'll try to Implement this on your OML.

Hope it helps,

Assif




Hi Assif,

How do I pass the array while navigating back to the previous screen?

Regards,

Shreyas Bhondve

Moreover, why can't I make use registerBackNavigationHandler in SearchHosital screen which is supposed to be invoked when navigating back from MyCalendar?


How do I pass the array while navigating back to the previous screen?

: Make Input variable on both Screens of Array Type, If you don't see then create a Structure first of that type & then use it.


Moreover, why can't I make use registerBackNavigationHandler in SearchHosital screen which is supposed to be invoked when navigating back from MyCalendar?

: registerBackNavigationHandler - Registers a callback function in a queue to be called when navigating back.

 So it is basically used in while you are dealing with Android so that you can identify the back-key event & use this to navigate back. 

Remember even though you navigate to the last Screen but in Outsystems while the navigation between the screens, the older screen is always removed from the DOM. Thus the previous Screen will be rendered again from initialize because the DOM of this screen is removed while navigating to other.

Ref:

https://success.outsystems.com/Documentation/11/Developing_an_Application/Implement_Application_Logic/Screen_and_Block_Lifecycle_Events


This means every child property of Screen i.e Variables or Aggregates will lose the memory & Data while you Navigate to another Screen.


Hope it helps,
Assif



Solution

Hi Shreyas Bhondve

Happy to know, you resolve the problem.

Thanks for Marking the same as Solution.

Cheers,

Assif