• Sumesh Chandran
  • NEWBIE
  • 135 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 43
    Replies
From the report below, every single row has the same Last Login value. I want to create a summary level formula with just time extracted and converted into minutes from one of those rows and create summary level formula. How can I make that happen? Please advise!

User-added image
I have a track variable which is declared as an array. When I push data to it, I get the error "Cannot read property 'push' of undefined". Also the console.log below get the correct length.
@track cities = [];

  markerClick(e) {
    let province = '';
    getCitiesByProvince({
      province: province,
    }).then(result => {
      console.log(result.length)
      for (let i = 0; i < result.length; i++) {
        this.cities.push(result[i]);
      }
    });
  }

 
I have been trying the corrections mentioned on the first answer of this post on Stackexchange https://salesforce.stackexchange.com/questions/254214/loading-the-leaflet-map-in-lightning-web-component (http://salesforce.stackexchange.com/questions/300839/leaflet-map-not-loading-on-page-load), still I get a blank div.
Here is my code so far:
 
HTML
<template>
  <div class="map-root" lwc:dom="manual"></div>
</template>

CSS
.map-root {
    height: 180px;
}

JAVASCRIPT
import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
import leaflet from '@salesforce/resourceUrl/leaflet'

export default class MduPenetration extends LightningElement {
  connectedCallback() {
    Promise.all([
      loadStyle(this, leaflet + '/leaflet.css'),
      loadScript(this, leaflet + '/leaflet.js')
    ]).then(() => {
      const el = this.template.querySelector('.map-root');
      const mymap = L.map(el).setView([51.505, -0.09], 13);
      L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={pk.ey********************************************}', {
        maxZoom: 18,
        id: 'mapbox.streets',
        accessToken: 'pk.ey********************************************'
      }).addTo(mymap);
    });
  }

And finally this is way I have the leaflet library uploaded to Static Resources:
User-added image
The below batch class will be processing a little over 2.5 million records. The START method will be sending in the whole 2.5 million records to the execute method and the execute method does the processing on each of the 2.5 million records inside a for loop. 
Also the for loop has a SOQL inside which I believe cannot be avoided to get the right numbers. 
Is this the right way of doing this or are there any other better ways. Please help!

Also when the running the below batch class I get the First Error: Too many query rows error.
 
global class MDUSquadRawDataBatchTest implements Database.Batchable<sObject>, Database.Stateful {  
    List<Address_Master__c> addressList = new List<Address_Master__c>();
    Set<String> addresses = new Set<String>();
   
    // Start Method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('SELECT Street_Address__c,City_Name__c FROM MDU_Squad_Raw_Data__c');
    }   
    
    // Execute method
    global void execute(Database.BatchableContext BC, List<MDU_Squad_Raw_Data__c> rawData) {        
        for(MDU_Squad_Raw_Data__c mduRawData: rawData) {
            List<MDU_Squad_Raw_Data__c> addressData = [SELECT Street_Address__c,City_Name__c,Province_Code__c,Postal_Code__c,Internet_Service__c,Video_Service__c,Phone_Service__c FROM MDU_Squad_Raw_Data__c WHERE Street_Address__c=:mduRawData.Street_Address__c AND City_Name__c=:mduRawData.City_Name__c];
            String fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
            
            Address_Master__c theAddress = new Address_Master__c();
            if(!addresses.contains(fullAddress.substringBeforeLast(' '))) {
                theAddress.Name = addressData[0].Street_Address__c;
                theAddress.City_Name__c = addressData[0].City_Name__c;
                theAddress.Province_Code__c = addressData[0].Province_Code__c;
                theAddress.Postal_Code__c = addressData[0].Postal_Code__c; 
                fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
                theAddress.Full_Address_Ext_Id__c = fullAddress;

                addresses.add(fullAddress.substringBeforeLast(' '));
                addressList.add(theAddress); 
            }                                                     
        }            
        Database.Upsert(addressList, Address_Master__c.Fields.Full_Address_Ext_Id__c, true);
    }
    // Finish Method    
    global void finish(Database.BatchableContext BC) {
        
    } 
}

I request if someone could please help me with this, as I am dealing with this for some time, with no idea on how to fix this.
I have a custom object named MDU_Squad to which I insert records using the Data Import Wizard. 
I have set 2 external ID fields in there, which are
1. Street_address [allow duplicates]
2. CIty_Name [allow duplicates]
Both the fields above have duplicate records as well.

I have created a batch class that pulls in all the records from the above MDU_Squad custom object and inserts into City_Master & Address_Master custom objects getting rid of all the duplicates. So at the end I will be having a master City_Master & Address_Master custom objects with no duplicates
The City_Master & Address_Master custom objects have external ids set, which are city_Name_Ext_Id & address_Ext_Id. Both the fields can't have any duplicates.

I am trying to use the upsert method, to have it insert if the record does not exist in the City_Master or Address_Master custom object or update if they exist in the object.
Here in the below code the addressList and the cityList objects have non-duplicate records which are extracted from the MDU_Squad which are to be saved to the Address_Master and City_Master custom objects.
 
Database.SaveResult[] saveAddressMaster = Database.Upsert(addressList, sumchans__MDU_Squad__c.STREET_ADDRESS__c, all);  
Database.SaveResult[] saveCityMaster = Database.Upsert(cityList, sumchans__MDU_Squad__c.City_Name__c, all);
Someone please help.

 
I want to load data in chunks when the scroll hits the bottom on a div element.
The variable 'ab' already has some data which is loaded when the app loads, here in the below code I am pulling in the next set of data and appending that data to the same 'ab' variable. For some reason I get HTML errors saying "[LWC error]: Invalid template iteration for value "undefined".
@track ab = [];

  @track abOffsetValue = 5;

theScroll(e) {
    let el = e.currentTarget;
    if(el.scrollHeight - el.scrollTop - el.clientHeight < 1){
      loadMoreCities ({
        province: e.target.dataset.id,
        offsetValue: this.abOffsetValue
      }).then(result => {
        this.ab.push(result);
        console.log(JSON.stringify(result));
      })
      .catch(error => {
        
      })
    }
  }
Here is the HTML
<lightning-card class="slds-p-right_small" variant="narrow" icon-name="utility:tracker">
    <h1 slot="title" style="font-style:normal; font-family:'Candara';"><strong>ALBERTA</strong></h1>
    <div id="abDiv" class="testClass" onscroll={theScroll} data-id="AB">
    <template for:each={ab} for:item="city">       
        <div class="flex-container" key={city.Id}>
            <div class="flex-box-1">
                <div style="color: rgb(28, 69, 145);"><strong>{city.Name}</strong></div>
            </div>
            <div style="display:flex;margin: 6px 30px 0px 30px;">
                <div>
                    <lightning-icon icon-name="utility:company" size="small"></lightning-icon>
                </div>
                <div style="margin:8px 0px 0px 3px; color:rgb(11, 59, 11);font-size:11.5px">
                    <b>{city.sumchans__Total_Buildings__c}</b>
                    <!-- <strong>10000000</strong></p> -->
                </div>
            </div>
            <div class="flex-box-2">
                <template for:each={city.sumchans__City_Stats__r} for:item="stats">
                    <div class="penetration slds-p-around_x-small" key={stats.Id}
                        style="color: rgb(197, 81, 61);font-size:14px">
                        <strong>{stats.sumchans__Penetration__c}%</strong></div>
                </template>
            </div>
        </div>
    </template>
</div>
</lightning-card>


 
User-added imageThe data attached above is stored in a trackable array in lightning js. I am trying to sort the data by desc using the sumchans__Total_Buildings__c value.
 Here is the function that receives the trackable array and does the sorting, but it doesn't work.
The console log logs the right value, that works.
Please advise!
sortCityByNumberOfBldgs(province) {
console.log(JSON.stringify(this.ab[1].sumchans__City_Stats__r[0].sumchans__Total_Buildings__c));
    theData = JSON.stringify(province);
    theData.sort(function (a, b) {
      return ((a.sumchans__City_Stats__r[0].sumchans__Total_Buildings__c) - (b.sumchans__City_Stats__r[0].sumchans__Total_Buildings__c)) ? 1 : 0;
    })
    this.ab = theData;
  }

 
Working on the new Salesforce Lightning web components. I am trying to get the multidimensional array sorted in javascript. I have a trackable array, it has a few columns, i want the data sorted by the total buildings value. Here is what I have done so far, no errors, but not getting the expected results.
@track bc = [];
@wire(getCityStats) cityStats({ data }) {
    if (data) {
      for (let i = 0; i < data.length; i++) {
        if (data[i].sumchans__Province_Code__c == 'BC') {
          this.bc.push(data[i]);
        }
      }
      sortCityByNumberOfBldgs(this.bc);
}
}
  sortCityByNumberOfBldgs(province) {
    province.sort(function(a,b) {
      return a[4]-b[4]
    });
  }

Here is the SOQL in the Apex controller:
SELECT Name,sumchans__Province_Code__c,
        (select sumchans__Penetration__c,sumchans__Total_Buildings__c from sumchans__City_Stats__r) FROM sumchans__CITY_MASTER__c
This is how the data gets displayed when I run the above query and this is the data that is getting stored in the trackable bc array above.
User-added image
 
I am having issues updating checkpoints in org. I have tried uninstalling and re-installing vscode, still it didn't work.
Below is the message I get when I try to update:
The local source is out of sync with the server. Push any changes you've made locally to your org, and pull any changes you've made in the org into your local project.
SFDX: Update Checkpoints in Org, Step 6 of 6: Confirming successful checkpoint creation
Ending SFDX: Update Checkpoints in Org
Your checkpoints have errors. Fix the errors listed in the output, then run SFDX: Update Checkpoints in Org again.


As per the message, I have done deploying and retrieving the source, still no use.

Please advise!
I am having issues updating checkpoints in org. I have tried uninstalling and re-installing vscode, still it didn't work.
Below is the message I get when I try to update:
The local source is out of sync with the server. Push any changes you've made locally to your org, and pull any changes you've made in the org into your local project.
SFDX: Update Checkpoints in Org, Step 6 of 6: Confirming successful checkpoint creation
Ending SFDX: Update Checkpoints in Org
Your checkpoints have errors. Fix the errors listed in the output, then run SFDX: Update Checkpoints in Org again.

As per the message, I have done deploying and retrieving the source, still no use.

Please advise!
I am trying to increment the values inside a list using the ++ operator, but I get the error saying 'Expression cannot be assigned'. On the code below I am trying the increment the values of onBillings & offBillings variable.
Decimal onBillings;
    Integer offBillings;
    List<sumchans__City_Master__c> cityList = new List<sumchans__City_Master__c>();//unique city list
    List<sumchans__City_Stats__c> cityStats = new List<sumchans__City_Stats__c>();//Saving city stats
    Set<String> cities = new Set<String>();
    for(sumchans__Address_Master__c addressMaster: addressList) {
          sumchans__City_Master__c city = new sumchans__City_Master__c();
          city.Name = addressMaster.sumchans__CITY_NAME__c;// Default Name column - storing city name
          city.sumchans__City_Name_Ext_Id__c = addressMaster.sumchans__CITY_NAME__c;//Populating the external id field with city name again to pull related data.
          city.sumchans__Province_Code__c = addressMaster.sumchans__PROVINCE_CODE__c;
          if(!cities.contains(city.Name)) {               
              for(sumchans__ADDRESS_STATS__c addressStatsList: addressStats) {
                  String cityFromAddressList = (addressStatsList.Name).substringBeforeLast(' ');
                  cityFromAddressList = cityFromAddressList.substringBeforeLast(' ');
                  if(cityFromAddressList == city.Name) {
                      onBillings++ = Integer.valueOf(addressStatsList.sumchans__On_Billings__c);
                      offBillings++ = addressStatsList.get('sumchans__Off_Billings__c');
                      sumchans__City_Stats__c cityStat = new sumchans__City_Stats__c();
                        cityStat.sumchans__On_Billings__c = onBillings;
                        cityStat.sumchans__Off_Billings__c = offBillings;
                        cityStats.add(cityStat);                       
                    }
                }
                cities.add(city.Name);
                cityList.add(city);
            } 
        }

 
I have a for loop running through a list which add items from one list to another list. The source list has 8 records, and the new list will get only 7 records.
for(sumchans__Address_Master__c city: addressList) {
            sumchans__City_Master__c theCity = new sumchans__City_Master__c();
            theCity.Name = city.sumchans__City_Name__c;
            theCity.sumchans__City_Name_Ext_Id__c = city.sumchans__City_Name__c;related data.
            theCity.sumchans__Province_Code__c = city.sumchans__Province_Code__c;
            cityList.add(theCity);
        }

Please help

THanks
Not sure if this is the way to accomplish this. I have a dataset column that needed to looped through and based on the values it should conditionally display them. I have this code copied four times to make this work, not sure how would I do it, if I weren't sure of the values coming in. 
<template>
    <div class="slds-grid slds-gutters slds-align_absolute-center">
        <div class="slds-col slds-size_2-of-12">
            <lightning-card title="BRITISH COLUMBIA">
                <hr class="titleDivider">
                    <template for:each={bc} for:item="city">
                        <lightning-layout class="slds-p-top_x-small" horizontal-align="spread" key={city.Id}>
                            <lightning-layout-item flexibility="auto" padding="horizontal-small">
                                <p style="color: rgb(67, 119, 214);"><strong>{city.Name}</strong></p>
                            </lightning-layout-item>
                            <lightning-layout-item class="slds-float_right" flexibility="auto" padding="horizontal-small">
                                <template for:each={city.sumchans__City_Stats__r} for:item="stats">
                                    <p key={stats.Id} style="color: rgb(224, 111, 91);"><strong>{stats.sumchans__Penetration__c}%</strong></p>
                                </template>
                            </lightning-layout-item>
                        </lightning-layout>
                    </template>
            </lightning-card>
        </div>
        <div class="slds-col slds-size_2-of-12">
            <lightning-card title="ALBERTA">
                <hr class="titleDivider">
                    <template for:each={ab} for:item="city">
                        <lightning-layout class="slds-p-top_x-small" horizontal-align="spread" key={city.Id}>
                            <lightning-layout-item flexibility="auto" padding="horizontal-small">
                                <p style="color: rgb(67, 119, 214);"><strong>{city.Name}</strong></p>
                            </lightning-layout-item>
                            <lightning-layout-item class="slds-float_right" flexibility="auto" padding="horizontal-small">
                                <template for:each={city.sumchans__City_Stats__r} for:item="stats">
                                    <p key={stats.Id} style="color: rgb(224, 111, 91);"><strong>{stats.sumchans__Penetration__c}%</strong></p>
                                </template>
                            </lightning-layout-item>
                        </lightning-layout
                    </template>
            </lightning-card>
        </div>
        <div class="slds-col slds-size_2-of-12">
            <lightning-card title="MANITOBA">
                <hr class="titleDivider">
                    <template for:each={mb} for:item="city">
                        <lightning-layout class="slds-p-top_x-small" horizontal-align="spread" key={city.Id}>
                            <lightning-layout-item flexibility="auto" padding="horizontal-small">
                                <p style="color: rgb(67, 119, 214);"><strong>{city.Name}</strong></p>
                            </lightning-layout-item>
                            <lightning-layout-item class="slds-float_right" flexibility="auto" padding="horizontal-small">
                                <template for:each={city.sumchans__City_Stats__r} for:item="stats">
                                    <p key={stats.Id} style="color: rgb(224, 111, 91);"><strong>{stats.sumchans__Penetration__c}%</strong></p>
                                </template>
                            </lightning-layout-item>
                        </lightning-layout>
                    </template>
            </lightning-card>
        </div>
        <div class="slds-col slds-size_2-of-12">
            <lightning-card title="SASKATCHEWAN">
                <hr class="titleDivider">
                    <template for:each={sk} for:item="city">
                        <lightning-layout class="slds-p-top_x-small" horizontal-align="spread" key={city.Id}>
                            <lightning-layout-item flexibility="auto" padding="horizontal-small">
                                <p style="color: rgb(67, 119, 214);"><strong>{city.Name}</strong></p>
                            </lightning-layout-item>
                            <lightning-layout-item class="slds-float_right" flexibility="auto" padding="horizontal-small">
                                <template for:each={city.sumchans__City_Stats__r} for:item="stats">
                                    <p key={stats.Id} style="color: rgb(224, 111, 91);"><strong>{stats.sumchans__Penetration__c}%</strong></p>
                                </template>
                            </lightning-layout-item>
                        </lightning-layout>
            </lightning-card>
        </div>
    </div>
</template>

The Javascript
import { LightningElement, wire, track } from "lwc";
import getCityStats from "@salesforce/apex/mduMarketAnalysisController.getCityStats";

export default class MduPenetration extends LightningElement {
  @track bc = [];
  @track ab = [];
  @track mb = [];
  @track sk = [];

  @wire(getCityStats) cityStats({ data }) {
    if (data) {
      for (let i = 0; i < data.length; i++) {
        if (data[i].sumchans__Province_Code__c == 'BC') {
          this.bc.push(data[i]);
        }
        if (data[i].sumchans__Province_Code__c == 'AB') {
          this.ab.push(data[i]);
        }
        if (data[i].sumchans__Province_Code__c == 'MB') {
          this.mb.push(data[i]);
        }
        if (data[i].sumchans__Province_Code__c == 'SK') {
          this.sk.push(data[i]);
        }
        //this.stats.push(data.value); 
      }
    }
  }
}

Please advise!
I am trying to display the value of a related custom object field along with the parent fields on my component html.
Here is the SOQL - The below works, I get the data of the child object with the values from the object
SELECT Name,sumchans__Province_Code__c,
    (select sumchans__Penetration__c, sumchans__Total_Units__c,sumchans__On_Billings__c, sumchans__Date_Of_Calculation__c 
    from sumchans__City_Stats__r) FROM sumchans__CITY_MASTER__c
Here is the wire service code:
import { LightningElement, wire } from 'lwc';
import getCityStats from '@salesforce/apex/mduMarketAnalysisController.getCityStats';  
export default class MduPenetration extends LightningElement {
    @wire(getCityStats)cityMaster;        
}

And here is the Component HTML. This just shows the parent fields values not anything from the child, but I don't get any errors.
 
<template if:true={cityMaster.data}>
            <template for:each={cityMaster.data} for:item="city">
                <lightning-layout horizontal-align="center" key={city.Id}>
                    <lightning-layout-Item>
                        {city.Name}
                    </lightning-layout-Item>
                    <lightning-layout-Item>
                        {city.sumchans__City_Stats__r.sumchans__Total_Units__c}
                    </lightning-layout-Item>
                </lightning-layout>                  
            </template>


 
I am trying to push the filter the data received from an apex method call and push it to a track variable @track variable. The below doesn't work, but no errors, no data is displayed.
export default class MduPenetration extends LightningElement {
  @track bc;
  @track ab;

  @wire(getCityStats) cityStats({data}) {
    if (data) {
        for(let i=0;i<data.length;i++) {
            if(data.sumchans__Province_Code__c == 'BC') {
                this.bc.push(data[i]);
            }
            if(data.sumchans__Province_Code__c == 'AB') {
                this.ab.push(data[i]);
            }
           //this.stats.push(data.value); 
        }
    }
  }
}
Here is the HTML
<template if:true={bc}>
                <template for:each={bc} for:item="city">
                    <lightning-layout class="slds-m-around_xxx-small" key={city.Name}>
                            <lightning-layout-Item>
                                {city.Name}
                            </lightning-layout-Item>
                            <lightning-layout-Item>
                                {city.sumchans__Province_Code__c}
                            </lightning-layout-Item>
                    </lightning-layout>
                </template>
            </template>
BUt simply this works
export default class MduPenetration extends LightningElement {
  @track stats;;
   @wire(getCityStats) cityStats({data}) {
       if (data) {
           this.stats = data; 
        }
    }
  }

Please advise!

 

 

I am trying to put the id from database.saveresult return values and then the matching value from the citylist list into this map below, but I get an error "Method does not exist or incorrect signature: void put(sumchans__City_Master__c, Id) from the type Map<String,String>"
 
Database.SaveResult[] saveCityMaster = Database.Insert(cityList, false);
        Map<String,String> findCityId = new Map<String,String>();
        for (Database.SaveResult sr : saveCityMaster) {
            if (!sr.isSuccess()) {
                findCityId.put(cityList.get(0),sr.getId());
            }
        }

 
I have been having a wierd issue for sometime now, I am not getting any system.debug messages on my logs, instead I get a lot of not useful stuff. I am trying to print out the value of 'stat' here, it doesn't work at all.
sumchans__City_Stat__c stat = new sumchans__City_Stat__c();
stat.sumchans__ON_BILLINGS__c = onBillings;
stat.sumchans__OFF_BILLINGS__c = offBillings;             stat.sumchans__TOTAL_INTERNET_OFFERINGS__c = internetOfferings;
stat.sumchans__TOTAL_VIDEO_OFFERINGS__c = videoOfferings;
stat.sumchans__TOTAL_PHONE_OFFERINGS__c = phoneOfferings;
cityStats.add(stat);
System.debug(stat);
And here is the full log list. I done want any of these messages as of now, what I am only looking for is the System.debug messages.
Plz advise!
Logs
 
I am trying to remove duplicates from a list. The list has duplicates in the city column and the province column.
This is what I tried according to what was mentioned on this post https://developer.salesforce.com/forums/?id=906F00000008y3SIAQ

It doesn't work for me. 
global void execute(Database.BatchableContext BC, List<MDU_Squad_Data_min__c> cities) {  
        Set<MDU_Squad_Data_min__c> citySet = new Set<MDU_Squad_Data_min__c>();
        citySet.addAll(cities);	
        List<MDU_Squad_Data_min__c> noDuplicateCityList = new List<MDU_Squad_Data_min__c>(citySet);
}
Please advise!
 
I have a list here which has city name as a column, how to filter the rows by values from the city name column.
global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('SELECT CITY_NAME__c,PROVINCE_CODE__c,STATUS__c,INTERNET_SERVICE__c,VIDEO_SERVICE__c,PHONE_SERVICE__c FROM MDU_Squad_Data_min__c');
    }
 
   // Execute method

    global void execute(Database.BatchableContext BC, List<MDU_Squad_Data_min__c> cityStats) {               
        // Here I am trying to filter the values of the cityStats list
    }

 
I am trying to use the DML statement to make an insert to the parent and child tables all at once.

I have got it to this point so far, I am not sure how to link the child to the parent when doing the insert in one command.

I tried following the instructions on the post below, got a bit confused. On the code there they use an external ID to make it happen which I am not sure about as I want the child objects to have the id of the parent record on its foreign key relationship field. I already have a master-detail relationship setup between the custom objects.

https://salesforce.stackexchange.com/questions/133906/insert-list-of-parent-and-child-records-in-one-dml-statement][1]

Here is what I go to so far. How do I link the 2 objects using the master-detail relationship setup and how to use the insert statement.
 
List<addressMaster__c> mduMaster = new List<addressMaster__c>();
            List<addressDetail__c> mduDetails = new List<addressDetail__c>();         
            Object[] values = (Object[])System.JSON.deserializeUntyped(mdus);
            for( Object mdu : values) {
                Map<String,Object> data = (Map<String,Object>)mdu;
                streetAddress = String.valueof(data.get('streetAddress'));
                totalUnits = Integer.valueof(data.get('totalUnits'));
                nnUnits = Integer.valueof(data.get('nnUnits'));            
                addressDetail__c newMduDetail = new addressDetail__c(Name=streetAddress,nnUnits__c=nnUnits,lastReportDate__c=DateTime.now());                                                         
                addressMaster__c newMduMaster = new addressMaster__c(Name=streetAddress,totalUnits__c=totalUnits);
                    
                mduDetails.add(newMduDetail);
                mduMaster.add(newMduMaster);
            }
Please advise!
 
The below batch class will be processing a little over 2.5 million records. The START method will be sending in the whole 2.5 million records to the execute method and the execute method does the processing on each of the 2.5 million records inside a for loop. 
Also the for loop has a SOQL inside which I believe cannot be avoided to get the right numbers. 
Is this the right way of doing this or are there any other better ways. Please help!

Also when the running the below batch class I get the First Error: Too many query rows error.
 
global class MDUSquadRawDataBatchTest implements Database.Batchable<sObject>, Database.Stateful {  
    List<Address_Master__c> addressList = new List<Address_Master__c>();
    Set<String> addresses = new Set<String>();
   
    // Start Method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('SELECT Street_Address__c,City_Name__c FROM MDU_Squad_Raw_Data__c');
    }   
    
    // Execute method
    global void execute(Database.BatchableContext BC, List<MDU_Squad_Raw_Data__c> rawData) {        
        for(MDU_Squad_Raw_Data__c mduRawData: rawData) {
            List<MDU_Squad_Raw_Data__c> addressData = [SELECT Street_Address__c,City_Name__c,Province_Code__c,Postal_Code__c,Internet_Service__c,Video_Service__c,Phone_Service__c FROM MDU_Squad_Raw_Data__c WHERE Street_Address__c=:mduRawData.Street_Address__c AND City_Name__c=:mduRawData.City_Name__c];
            String fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
            
            Address_Master__c theAddress = new Address_Master__c();
            if(!addresses.contains(fullAddress.substringBeforeLast(' '))) {
                theAddress.Name = addressData[0].Street_Address__c;
                theAddress.City_Name__c = addressData[0].City_Name__c;
                theAddress.Province_Code__c = addressData[0].Province_Code__c;
                theAddress.Postal_Code__c = addressData[0].Postal_Code__c; 
                fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
                theAddress.Full_Address_Ext_Id__c = fullAddress;

                addresses.add(fullAddress.substringBeforeLast(' '));
                addressList.add(theAddress); 
            }                                                     
        }            
        Database.Upsert(addressList, Address_Master__c.Fields.Full_Address_Ext_Id__c, true);
    }
    // Finish Method    
    global void finish(Database.BatchableContext BC) {
        
    } 
}

I request if someone could please help me with this, as I am dealing with this for some time, with no idea on how to fix this.
I have a track variable which is declared as an array. When I push data to it, I get the error "Cannot read property 'push' of undefined". Also the console.log below get the correct length.
@track cities = [];

  markerClick(e) {
    let province = '';
    getCitiesByProvince({
      province: province,
    }).then(result => {
      console.log(result.length)
      for (let i = 0; i < result.length; i++) {
        this.cities.push(result[i]);
      }
    });
  }

 
The below batch class will be processing a little over 2.5 million records. The START method will be sending in the whole 2.5 million records to the execute method and the execute method does the processing on each of the 2.5 million records inside a for loop. 
Also the for loop has a SOQL inside which I believe cannot be avoided to get the right numbers. 
Is this the right way of doing this or are there any other better ways. Please help!

Also when the running the below batch class I get the First Error: Too many query rows error.
 
global class MDUSquadRawDataBatchTest implements Database.Batchable<sObject>, Database.Stateful {  
    List<Address_Master__c> addressList = new List<Address_Master__c>();
    Set<String> addresses = new Set<String>();
   
    // Start Method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('SELECT Street_Address__c,City_Name__c FROM MDU_Squad_Raw_Data__c');
    }   
    
    // Execute method
    global void execute(Database.BatchableContext BC, List<MDU_Squad_Raw_Data__c> rawData) {        
        for(MDU_Squad_Raw_Data__c mduRawData: rawData) {
            List<MDU_Squad_Raw_Data__c> addressData = [SELECT Street_Address__c,City_Name__c,Province_Code__c,Postal_Code__c,Internet_Service__c,Video_Service__c,Phone_Service__c FROM MDU_Squad_Raw_Data__c WHERE Street_Address__c=:mduRawData.Street_Address__c AND City_Name__c=:mduRawData.City_Name__c];
            String fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
            
            Address_Master__c theAddress = new Address_Master__c();
            if(!addresses.contains(fullAddress.substringBeforeLast(' '))) {
                theAddress.Name = addressData[0].Street_Address__c;
                theAddress.City_Name__c = addressData[0].City_Name__c;
                theAddress.Province_Code__c = addressData[0].Province_Code__c;
                theAddress.Postal_Code__c = addressData[0].Postal_Code__c; 
                fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
                theAddress.Full_Address_Ext_Id__c = fullAddress;

                addresses.add(fullAddress.substringBeforeLast(' '));
                addressList.add(theAddress); 
            }                                                     
        }            
        Database.Upsert(addressList, Address_Master__c.Fields.Full_Address_Ext_Id__c, true);
    }
    // Finish Method    
    global void finish(Database.BatchableContext BC) {
        
    } 
}

I request if someone could please help me with this, as I am dealing with this for some time, with no idea on how to fix this.
I have a custom object named MDU_Squad to which I insert records using the Data Import Wizard. 
I have set 2 external ID fields in there, which are
1. Street_address [allow duplicates]
2. CIty_Name [allow duplicates]
Both the fields above have duplicate records as well.

I have created a batch class that pulls in all the records from the above MDU_Squad custom object and inserts into City_Master & Address_Master custom objects getting rid of all the duplicates. So at the end I will be having a master City_Master & Address_Master custom objects with no duplicates
The City_Master & Address_Master custom objects have external ids set, which are city_Name_Ext_Id & address_Ext_Id. Both the fields can't have any duplicates.

I am trying to use the upsert method, to have it insert if the record does not exist in the City_Master or Address_Master custom object or update if they exist in the object.
Here in the below code the addressList and the cityList objects have non-duplicate records which are extracted from the MDU_Squad which are to be saved to the Address_Master and City_Master custom objects.
 
Database.SaveResult[] saveAddressMaster = Database.Upsert(addressList, sumchans__MDU_Squad__c.STREET_ADDRESS__c, all);  
Database.SaveResult[] saveCityMaster = Database.Upsert(cityList, sumchans__MDU_Squad__c.City_Name__c, all);
Someone please help.

 
I am trying to increment the values inside a list using the ++ operator, but I get the error saying 'Expression cannot be assigned'. On the code below I am trying the increment the values of onBillings & offBillings variable.
Decimal onBillings;
    Integer offBillings;
    List<sumchans__City_Master__c> cityList = new List<sumchans__City_Master__c>();//unique city list
    List<sumchans__City_Stats__c> cityStats = new List<sumchans__City_Stats__c>();//Saving city stats
    Set<String> cities = new Set<String>();
    for(sumchans__Address_Master__c addressMaster: addressList) {
          sumchans__City_Master__c city = new sumchans__City_Master__c();
          city.Name = addressMaster.sumchans__CITY_NAME__c;// Default Name column - storing city name
          city.sumchans__City_Name_Ext_Id__c = addressMaster.sumchans__CITY_NAME__c;//Populating the external id field with city name again to pull related data.
          city.sumchans__Province_Code__c = addressMaster.sumchans__PROVINCE_CODE__c;
          if(!cities.contains(city.Name)) {               
              for(sumchans__ADDRESS_STATS__c addressStatsList: addressStats) {
                  String cityFromAddressList = (addressStatsList.Name).substringBeforeLast(' ');
                  cityFromAddressList = cityFromAddressList.substringBeforeLast(' ');
                  if(cityFromAddressList == city.Name) {
                      onBillings++ = Integer.valueOf(addressStatsList.sumchans__On_Billings__c);
                      offBillings++ = addressStatsList.get('sumchans__Off_Billings__c');
                      sumchans__City_Stats__c cityStat = new sumchans__City_Stats__c();
                        cityStat.sumchans__On_Billings__c = onBillings;
                        cityStat.sumchans__Off_Billings__c = offBillings;
                        cityStats.add(cityStat);                       
                    }
                }
                cities.add(city.Name);
                cityList.add(city);
            } 
        }

 
I have a for loop running through a list which add items from one list to another list. The source list has 8 records, and the new list will get only 7 records.
for(sumchans__Address_Master__c city: addressList) {
            sumchans__City_Master__c theCity = new sumchans__City_Master__c();
            theCity.Name = city.sumchans__City_Name__c;
            theCity.sumchans__City_Name_Ext_Id__c = city.sumchans__City_Name__c;related data.
            theCity.sumchans__Province_Code__c = city.sumchans__Province_Code__c;
            cityList.add(theCity);
        }

Please help

THanks
I am trying to display the value of a related custom object field along with the parent fields on my component html.
Here is the SOQL - The below works, I get the data of the child object with the values from the object
SELECT Name,sumchans__Province_Code__c,
    (select sumchans__Penetration__c, sumchans__Total_Units__c,sumchans__On_Billings__c, sumchans__Date_Of_Calculation__c 
    from sumchans__City_Stats__r) FROM sumchans__CITY_MASTER__c
Here is the wire service code:
import { LightningElement, wire } from 'lwc';
import getCityStats from '@salesforce/apex/mduMarketAnalysisController.getCityStats';  
export default class MduPenetration extends LightningElement {
    @wire(getCityStats)cityMaster;        
}

And here is the Component HTML. This just shows the parent fields values not anything from the child, but I don't get any errors.
 
<template if:true={cityMaster.data}>
            <template for:each={cityMaster.data} for:item="city">
                <lightning-layout horizontal-align="center" key={city.Id}>
                    <lightning-layout-Item>
                        {city.Name}
                    </lightning-layout-Item>
                    <lightning-layout-Item>
                        {city.sumchans__City_Stats__r.sumchans__Total_Units__c}
                    </lightning-layout-Item>
                </lightning-layout>                  
            </template>


 
I am trying to push the filter the data received from an apex method call and push it to a track variable @track variable. The below doesn't work, but no errors, no data is displayed.
export default class MduPenetration extends LightningElement {
  @track bc;
  @track ab;

  @wire(getCityStats) cityStats({data}) {
    if (data) {
        for(let i=0;i<data.length;i++) {
            if(data.sumchans__Province_Code__c == 'BC') {
                this.bc.push(data[i]);
            }
            if(data.sumchans__Province_Code__c == 'AB') {
                this.ab.push(data[i]);
            }
           //this.stats.push(data.value); 
        }
    }
  }
}
Here is the HTML
<template if:true={bc}>
                <template for:each={bc} for:item="city">
                    <lightning-layout class="slds-m-around_xxx-small" key={city.Name}>
                            <lightning-layout-Item>
                                {city.Name}
                            </lightning-layout-Item>
                            <lightning-layout-Item>
                                {city.sumchans__Province_Code__c}
                            </lightning-layout-Item>
                    </lightning-layout>
                </template>
            </template>
BUt simply this works
export default class MduPenetration extends LightningElement {
  @track stats;;
   @wire(getCityStats) cityStats({data}) {
       if (data) {
           this.stats = data; 
        }
    }
  }

Please advise!

 

 

I am trying to put the id from database.saveresult return values and then the matching value from the citylist list into this map below, but I get an error "Method does not exist or incorrect signature: void put(sumchans__City_Master__c, Id) from the type Map<String,String>"
 
Database.SaveResult[] saveCityMaster = Database.Insert(cityList, false);
        Map<String,String> findCityId = new Map<String,String>();
        for (Database.SaveResult sr : saveCityMaster) {
            if (!sr.isSuccess()) {
                findCityId.put(cityList.get(0),sr.getId());
            }
        }