ALPHA: How to handle API across pages and handle refresh in a multi-page application?

Hi,

@Sam @Simphiwe @Eldho

In my application,onLoad lands on the Customer Information page, where I execute the getSubmission data API to fetch all submission details from the database. I need these submission details to be available across all pages.

Currently, I store the data in a local variable and use it throughout the pages. However, when the user is on the Service page and refreshes the tab, all local variables are cleared, and the app reloads on the Service page.

  1. Is there a way to make the user land on the Customer Information page every time they refresh?
  2. Alternatively, is there a way to conditionally execute APIs so that the required data is fetched again without forcing navigation?

1 Like

@Sam please support asap

1 Like

Hi @Vignesh-U,

On Alpha studio everything assigned to local or co inside the alpha object it is accessible across all the pages when navigating to other pages untill the whole application is refreshed/loaded.
If you want data to be available even after refresh you can use localstorage.

  1. What you can try doing is checking on Before Init if the submission data is available on local if not route a user back to Customer Information page.
  2. I don’t think the is a way unless if you doing it on the custom code which becomes messy.
2 Likes

In Alpha Studio, since data stored in the alpha.local or alpha.co object is only retained during navigation and lost after a full refresh, how can I persist form submission data more cleanly—without relying on messy custom code or manually managing localStorage?

1 Like

Hello @Edward ,
You can try using the case service — the data will persist with that approach. Hope this helps!

1 Like

Thanks @Sam will try that.

Hi @Simphiwe ,

My submission api will get data from DB, we are not using the case services to store the data.

Browser LocalStorage will not be helpful when we have multiple tabs.

If routing back user to customer page is the only option, It will increase the application load time

Alternatively, is there a way to conditionally execute APIs so that the required data is fetched again without forcing navigation?

Hi @Vignesh-U,

Yes it is possible on the custom code.