Skip to main content
added code
Source Link
itzmukeshy7
  • 3.2k
  • 21
  • 31

Yes, we can achieve this. We have to do these steps:

  1. Create a LWC/Aura component that can show toast message.
  2. The Aura component will use localStorage to track whether it's first time if yes then we will show the toast and update in localStorage.
  3. And if it's not first time then we simply skip the toast message.
  4. This component will not have any UI elements.
  5. Now drop the component on the home page using edit page.
  6. Logout and login again and you should see toast when you visit the page first time.

Here is the sample code of AURA:

var alertisFirstView = sessionStoragelocalStorage.getItem('alert''isFirstView') || '';
if (alertisFirstView !=== 'Yes') {
toastEvent.fire(); /   /Fire* toastShow eventmessage to use as this is first view. */
sessionStorage    localStorage.setItem('alert''isFirstView', 'Yes');
}

With sessionStorage, you can display message once when you log in to application first time. If you refresh the page then message do not appear. But if you close the browser and login again, it again display the message.

With localStorage, you can display message once after that you close the broswer and login again, it does not display.

In my requirement I wanted to use local storage.

Yes, we can achieve this. We have to do these steps:

  1. Create a LWC/Aura component that can show toast message.
  2. The Aura component will use localStorage to track whether it's first time if yes then we will show the toast and update in localStorage.
  3. And if it's not first time then we simply skip the toast message.
  4. This component will not have any UI elements.
  5. Now drop the component on the home page using edit page.
  6. Logout and login again and you should see toast when you visit the page first time.

Here is the sample code of AURA:

var alert = sessionStorage.getItem('alert') || '';
if (alert != 'Yes') {
toastEvent.fire(); //Fire toast event 
sessionStorage.setItem('alert','Yes');
}

With sessionStorage, you can display message once when you log in to application first time. If you refresh the page then message do not appear. But if you close the browser and login again, it again display the message.

With localStorage, you can display message once after that you close the broswer and login again, it does not display.

In my requirement I wanted to use local storage.

Yes, we can achieve this. We have to do these steps:

  1. Create a LWC/Aura component that can show toast message.
  2. The Aura component will use localStorage to track whether it's first time if yes then we will show the toast and update in localStorage.
  3. And if it's not first time then we simply skip the toast message.
  4. This component will not have any UI elements.
  5. Now drop the component on the home page using edit page.
  6. Logout and login again and you should see toast when you visit the page first time.

Here is the sample code of AURA:

var isFirstView = localStorage.getItem('isFirstView') || '';
if (isFirstView !== 'Yes') {
    /* Show message to use as this is first view. */
    localStorage.setItem('isFirstView', 'Yes');
}

In my requirement I wanted to use local storage.

Yes, we can achieve this. We have to do these steps:

  1. Create a LWC/Aura component that can show toast message.
  2. The Aura component will use localStorage to track whether it's first time if yes then we will show the toast and update in localStorage.
  3. And if it's not first time then we simply skip the toast message.
  4. This component will not have any UI elements.
  5. Now drop the component on the home page using edit page.
  6. Logout and login again and you should see toast when you visit the page first time.

Here is the sample code of AURA:

var alert = sessionStorage.getItem('alert') || '';
if (alert != 'Yes') {
toastEvent.fire(); //Fire toast event 
sessionStorage.setItem('alert','Yes');
}

With sessionStorage, you can display message once when you log in to application first time. If you refresh the page then message do not appear. But if you close the browser and login again, it again display the message.

With localStorage, you can display message once after that you close the broswer and login again, it does not display.

In my requirement I wanted to use local storage.

Yes, we can achieve this. We have to do these steps:

  1. Create a LWC/Aura component that can show toast message.
  2. The Aura component will use localStorage to track whether it's first time if yes then we will show the toast and update in localStorage.
  3. And if it's not first time then we simply skip the toast message.
  4. This component will not have any UI elements.
  5. Now drop the component on the home page using edit page.
  6. Logout and login again and you should see toast when you visit the page first time.

Yes, we can achieve this. We have to do these steps:

  1. Create a LWC/Aura component that can show toast message.
  2. The Aura component will use localStorage to track whether it's first time if yes then we will show the toast and update in localStorage.
  3. And if it's not first time then we simply skip the toast message.
  4. This component will not have any UI elements.
  5. Now drop the component on the home page using edit page.
  6. Logout and login again and you should see toast when you visit the page first time.

Here is the sample code of AURA:

var alert = sessionStorage.getItem('alert') || '';
if (alert != 'Yes') {
toastEvent.fire(); //Fire toast event 
sessionStorage.setItem('alert','Yes');
}

With sessionStorage, you can display message once when you log in to application first time. If you refresh the page then message do not appear. But if you close the browser and login again, it again display the message.

With localStorage, you can display message once after that you close the broswer and login again, it does not display.

In my requirement I wanted to use local storage.

Source Link
itzmukeshy7
  • 3.2k
  • 21
  • 31

Yes, we can achieve this. We have to do these steps:

  1. Create a LWC/Aura component that can show toast message.
  2. The Aura component will use localStorage to track whether it's first time if yes then we will show the toast and update in localStorage.
  3. And if it's not first time then we simply skip the toast message.
  4. This component will not have any UI elements.
  5. Now drop the component on the home page using edit page.
  6. Logout and login again and you should see toast when you visit the page first time.