function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vishwas B NVishwas B N 

Properties defaulting to its original values

Hi team,

I have a navigation from one app page(let A) to another app page((let B) and back to original page.

When i navigate to page B, i store current value of the properties to localstorage. When i comeback to page A i get the value form the local storage and set it to the property, but when i call a function the property values are defaulted to the original values.

Can you please help me how can i retain the assigned values.

Below are the code snippet(LWC):

connectedCallback() {
        loadStyle(this, HideLightningHeader);
        this.setdepartmentvalues();
        this.decideview();
    }

    
    decideview() { 
        var scheduledata = JSON.parse(localStorage.getItem('scheduledata'));
        if (scheduledata == undefined || scheduledata == null) { // works when page loaded for first time
            this.loadscheduleboarddata();
        }
        else { // this works whn navigated from page B to page A
            this.selectedbustype = scheduledata.selectedbustype;  //new assigned value
            this.selectedcustomer = scheduledata.selectedcustomer; //new assigned value
            this.selectedDate = scheduledata.selectedDate; //new assigned value
            this.selectedpropulsion = scheduledata.selectedpropulsion; //new assigned value
            this.selectedbusstatus = scheduledata.selectedbusstatus; //new assigned value
            this.partShortageFilter = scheduledata.partShortageFilter; //new assigned value
            this.discrepancyFilter = scheduledata.discrepancyFilter; //new assigned value
            localStorage.removeItem('scheduledata');
            this.handleallFilterchanges();
        }
    }
    
    handleallFilterchanges(event) {
    var selectedbustype = this.selectedBusType;    //value defaulted to original
    var selectedcustomer = this.selectedCustomer;  //value defaulted to original
    var selectedDate = this.dateFieldValue;          //value defaulted to original        
    var selectedpropulsion = this.selectedBusPropulsion; //value defaulted to original
    var selectedbusstatus = this.selectedBusStatus;    //value defaulted to original
    var partShortageFilter = this.partShortageFilter; //value defaulted to original
    var discrepancyFilter = this.discrepancyFilter; //value defaulted to original
    //other code for logic
    .
    .
    .
    }

 
Donnelly LivingstonDonnelly Livingston
You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.

StopElon (https://stopelon.org)