Skip to main content
added 8428 characters in body
Source Link

Controller

@AuraEnabled
    public static ListMapWrapper getMergeLeadRecord ( list<string> Indexing ) {
        wrapmap = new Map<string, List<dataWrapperClass>>();
        system.debug('Indexing : '+Indexing); 
        list<string> tempstringID = new list<string>();
        for(integer i = 0 ;i < Indexing.size(); i++){
            tempstringID.add(Indexing[i]);
        }
        system.debug('tempstringID : '+tempstringID); 
        if(tempstringID.size()<=0){
            return null;
        }
        
        String objName ='Account';
        
        if (Schema.sObjectType.Account.isAccessible()){
            
            Map<String, Schema.SObjectField> objectFields = new Map<String, Schema.SObjectField>();
            
            Schema.SObjectType convertType = Schema.getGlobalDescribe().get(objName);
            Schema.DescribeSObjectResult r = convertType.getDescribe();    
            objectFields = Schema.getGlobalDescribe().get(objName).getDescribe().fields.getMap();
            
            List<String> fieldlist = new List<String>();
            Set<String> aPINamesSet = objectFields.keyset();
            fieldlist.addAll(aPINamesSet);
            system.debug('fieldlist : '+fieldlist); 
            string soqlQueryCurrent = string.join(fieldlist,',');
            
            if(soqlQueryCurrent.endsWithIgnoreCase(',')){
                soqlQueryCurrent = soqlQueryCurrent.removeEndIgnoreCase(',');                  
            }
            String queryStr ='SELECT '+soqlQueryCurrent+' FROM '+objName+' where Id =:tempstringID';  
            system.debug('queryStr : '+queryStr);            
            List <Sobject> finalLeadListRecord = Database.query(String.escapeSingleQuotes(queryStr));
            system.debug('finalLeadListRecord : '+finalLeadListRecord);       
            Set<SObjectField> accessibleFields = new Set<SObjectField>();
            
            SObjectType sObjectType = Schema.getGlobalDescribe().get('Account');
            for (SObjectField field : sObjectType.getDescribe().fields.getMap().values()){
                if (field.getDescribe().isAccessible() && field.getDescribe().isUpdateable() ){
                    system.debug('Object accessible '); 
                    accessibleFields.add(field);
                }
            }
            
            for(Sobject ld : finalLeadListRecord){
                String jsonInput = System.Json.serialize(ld);
                system.debug('jsonInput '+jsonInput); 
                Map<String, Object> soqlresMap = (Map<String, Object>)JSON.deserializeUntyped(jsonInput);
                
                List<dataWrapperClass> tempStrings = new List<dataWrapperClass>();
                String ssmap = 'Id';
                if(ssmap == 'Id' || ssmap == 'id'){
                    String tempVal = null;
                    String tempValID = null;
                    ssmap = 'Id (Master Record)';
                    tempVal = String.valueOf(soqlresMap.get('Name'));
                    tempValID  = String.valueOf(soqlresMap.get('Id'));
                    if(wrapmap.containskey(ssmap)){
                        tempStrings = wrapmap.get(ssmap);                        
                        dataWrapperClass dcpw = new dataWrapperClass();
                        dcpw.FieldValue = tempVal;
                        dcpw.FieldAPIName = ssmap;
                        dcpw.FieldAPINameOrValue = tempValID;
                        tempStrings.add(dcpw);
                        
                    }
                    else{
                        dataWrapperClass dcpw = new dataWrapperClass();
                        if(ssmap == 'Id (Master Record)'){
                            dcpw.FieldAPIName = tempVal;
                            dcpw.FieldValue = tempVal;
                            dcpw.RadioButton = true;
                            dcpw.FieldAPINameOrValue = tempValID;
                        }
                        tempStrings.add(dcpw);
                        wrapmap.put(ssmap,tempStrings); 
                    }
                }
                
                for(SObjectField accField : accessibleFields){
                    String accFields = String.valueOf(accField);
                    
                    if(accFields != 'Attributes' && accFields != 'PhotoURL' && accFields != 'Lastreferencedate' && accFields != 'IsDeleted' && accFields != 'Name' && accFields != 'Address'
                       && accFields != 'OwnerId' && accFields != 'CreatedDate' && accFields != 'CreatedById' && accFields != 'Lastmodifieddate' && accFields != 'LastmodifiedbyId' && accFields != 'SystemModstamp'
                       && accFields != 'Lastvieweddate' && accFields != 'LastReferencedDate' && accFields != 'lastTransferDate'  && accFields != 'IsConverted'){
                           List<dataWrapperClass> tempString = new List<dataWrapperClass>();
                           system.debug('Inside restricted field condition');
                           String tempVal = null;
                           String tempValID = null;
                           
                           if(accFields == 'Id'){
                               accFields = 'Id (Master Record)';
                               tempVal = String.valueOf(soqlresMap.get('Id'));
                               tempValID  = String.valueOf(soqlresMap.get('Id'));
                           }
                           else{
                               tempVal = String.valueOf(soqlresMap.get(accFields));
                               tempValID  = String.valueOf(soqlresMap.get('Id'));
                           }
                           
                           if(wrapmap.containskey(accFields)){
                               tempString = wrapmap.get(accFields);                        
                               dataWrapperClass dcpw = new dataWrapperClass();
                               dcpw.FieldValue = tempVal;
                               dcpw.FieldAPIName = accFields;
                               dcpw.FieldAPINameOrValue = tempValID;
                               tempString.add(dcpw);
                               
                           }
                           else{
                               dataWrapperClass dcpw = new dataWrapperClass();
                               if(accFields == 'Id (Master Record)'){
                                   dcpw.FieldAPIName = tempVal;
                                   dcpw.FieldValue = tempVal;
                                   dcpw.RadioButton = true;
                                   dcpw.FieldAPINameOrValue = tempValID;
                               }
                               else{
                                   dcpw.FieldAPIName = accFields;
                                   dcpw.FieldValue = tempVal;
                                   dcpw.RadioButton = false;
                                   dcpw.FieldAPINameOrValue = tempValID;
                               }
                               tempString.add(dcpw);
                               wrapmap.put(accFields,tempString); 
                           }
                       }
                }
            }
            
            try{
                if(wrapmap.size()>0){
                    wrapmap = updateMapFieldsValue(wrapmap);
                }
            }
            catch(Exception e){
                system.debug(' : '+e.getCause());
                system.debug(' : '+e.getLineNumber());
                system.debug(' : '+e.getMessage());
                system.debug(' : '+e.getTypeName());
            }            
                        
            List<ParentWrapper> results = new List<ParentWrapper>();
            for(String key : wrapmap.keySet()){
                ParentWrapper pw = new ParentWrapper(key, wrapmap.get(key));
                results.add(pw);
            }
            
            ListMapWrapper lmw = new ListMapWrapper();
            lmw.tableTemp = results;
            lmw.mapTemp = wrapmap; 
            system.debug('lmw : '+lmw);       
            return lmw;
        } 
        else{
            ListMapWrapper lmw = new ListMapWrapper();
            return lmw;
        }
    }

Controller

@AuraEnabled
    public static ListMapWrapper getMergeLeadRecord ( list<string> Indexing ) {
        wrapmap = new Map<string, List<dataWrapperClass>>();
        system.debug('Indexing : '+Indexing); 
        list<string> tempstringID = new list<string>();
        for(integer i = 0 ;i < Indexing.size(); i++){
            tempstringID.add(Indexing[i]);
        }
        system.debug('tempstringID : '+tempstringID); 
        if(tempstringID.size()<=0){
            return null;
        }
        
        String objName ='Account';
        
        if (Schema.sObjectType.Account.isAccessible()){
            
            Map<String, Schema.SObjectField> objectFields = new Map<String, Schema.SObjectField>();
            
            Schema.SObjectType convertType = Schema.getGlobalDescribe().get(objName);
            Schema.DescribeSObjectResult r = convertType.getDescribe();    
            objectFields = Schema.getGlobalDescribe().get(objName).getDescribe().fields.getMap();
            
            List<String> fieldlist = new List<String>();
            Set<String> aPINamesSet = objectFields.keyset();
            fieldlist.addAll(aPINamesSet);
            system.debug('fieldlist : '+fieldlist); 
            string soqlQueryCurrent = string.join(fieldlist,',');
            
            if(soqlQueryCurrent.endsWithIgnoreCase(',')){
                soqlQueryCurrent = soqlQueryCurrent.removeEndIgnoreCase(',');                  
            }
            String queryStr ='SELECT '+soqlQueryCurrent+' FROM '+objName+' where Id =:tempstringID';  
            system.debug('queryStr : '+queryStr);            
            List <Sobject> finalLeadListRecord = Database.query(String.escapeSingleQuotes(queryStr));
            system.debug('finalLeadListRecord : '+finalLeadListRecord);       
            Set<SObjectField> accessibleFields = new Set<SObjectField>();
            
            SObjectType sObjectType = Schema.getGlobalDescribe().get('Account');
            for (SObjectField field : sObjectType.getDescribe().fields.getMap().values()){
                if (field.getDescribe().isAccessible() && field.getDescribe().isUpdateable() ){
                    system.debug('Object accessible '); 
                    accessibleFields.add(field);
                }
            }
            
            for(Sobject ld : finalLeadListRecord){
                String jsonInput = System.Json.serialize(ld);
                system.debug('jsonInput '+jsonInput); 
                Map<String, Object> soqlresMap = (Map<String, Object>)JSON.deserializeUntyped(jsonInput);
                
                List<dataWrapperClass> tempStrings = new List<dataWrapperClass>();
                String ssmap = 'Id';
                if(ssmap == 'Id' || ssmap == 'id'){
                    String tempVal = null;
                    String tempValID = null;
                    ssmap = 'Id (Master Record)';
                    tempVal = String.valueOf(soqlresMap.get('Name'));
                    tempValID  = String.valueOf(soqlresMap.get('Id'));
                    if(wrapmap.containskey(ssmap)){
                        tempStrings = wrapmap.get(ssmap);                        
                        dataWrapperClass dcpw = new dataWrapperClass();
                        dcpw.FieldValue = tempVal;
                        dcpw.FieldAPIName = ssmap;
                        dcpw.FieldAPINameOrValue = tempValID;
                        tempStrings.add(dcpw);
                        
                    }
                    else{
                        dataWrapperClass dcpw = new dataWrapperClass();
                        if(ssmap == 'Id (Master Record)'){
                            dcpw.FieldAPIName = tempVal;
                            dcpw.FieldValue = tempVal;
                            dcpw.RadioButton = true;
                            dcpw.FieldAPINameOrValue = tempValID;
                        }
                        tempStrings.add(dcpw);
                        wrapmap.put(ssmap,tempStrings); 
                    }
                }
                
                for(SObjectField accField : accessibleFields){
                    String accFields = String.valueOf(accField);
                    
                    if(accFields != 'Attributes' && accFields != 'PhotoURL' && accFields != 'Lastreferencedate' && accFields != 'IsDeleted' && accFields != 'Name' && accFields != 'Address'
                       && accFields != 'OwnerId' && accFields != 'CreatedDate' && accFields != 'CreatedById' && accFields != 'Lastmodifieddate' && accFields != 'LastmodifiedbyId' && accFields != 'SystemModstamp'
                       && accFields != 'Lastvieweddate' && accFields != 'LastReferencedDate' && accFields != 'lastTransferDate'  && accFields != 'IsConverted'){
                           List<dataWrapperClass> tempString = new List<dataWrapperClass>();
                           system.debug('Inside restricted field condition');
                           String tempVal = null;
                           String tempValID = null;
                           
                           if(accFields == 'Id'){
                               accFields = 'Id (Master Record)';
                               tempVal = String.valueOf(soqlresMap.get('Id'));
                               tempValID  = String.valueOf(soqlresMap.get('Id'));
                           }
                           else{
                               tempVal = String.valueOf(soqlresMap.get(accFields));
                               tempValID  = String.valueOf(soqlresMap.get('Id'));
                           }
                           
                           if(wrapmap.containskey(accFields)){
                               tempString = wrapmap.get(accFields);                        
                               dataWrapperClass dcpw = new dataWrapperClass();
                               dcpw.FieldValue = tempVal;
                               dcpw.FieldAPIName = accFields;
                               dcpw.FieldAPINameOrValue = tempValID;
                               tempString.add(dcpw);
                               
                           }
                           else{
                               dataWrapperClass dcpw = new dataWrapperClass();
                               if(accFields == 'Id (Master Record)'){
                                   dcpw.FieldAPIName = tempVal;
                                   dcpw.FieldValue = tempVal;
                                   dcpw.RadioButton = true;
                                   dcpw.FieldAPINameOrValue = tempValID;
                               }
                               else{
                                   dcpw.FieldAPIName = accFields;
                                   dcpw.FieldValue = tempVal;
                                   dcpw.RadioButton = false;
                                   dcpw.FieldAPINameOrValue = tempValID;
                               }
                               tempString.add(dcpw);
                               wrapmap.put(accFields,tempString); 
                           }
                       }
                }
            }
            
            try{
                if(wrapmap.size()>0){
                    wrapmap = updateMapFieldsValue(wrapmap);
                }
            }
            catch(Exception e){
                system.debug(' : '+e.getCause());
                system.debug(' : '+e.getLineNumber());
                system.debug(' : '+e.getMessage());
                system.debug(' : '+e.getTypeName());
            }            
                        
            List<ParentWrapper> results = new List<ParentWrapper>();
            for(String key : wrapmap.keySet()){
                ParentWrapper pw = new ParentWrapper(key, wrapmap.get(key));
                results.add(pw);
            }
            
            ListMapWrapper lmw = new ListMapWrapper();
            lmw.tableTemp = results;
            lmw.mapTemp = wrapmap; 
            system.debug('lmw : '+lmw);       
            return lmw;
        } 
        else{
            ListMapWrapper lmw = new ListMapWrapper();
            return lmw;
        }
    }
Source Link

Uncaught (in promise) TypeError: e[eo] is not a function error in lwc

Getting the error when I iterate my data variable in for:each.Below is the snip of the values that is fetched in the data variable.Please help!

enter image description here

HTML

<table class="slds-table slds-table_cell-buffer slds-table_bordered">
                        <template for:each={data} for:item="con">
                            <tr key={con.key}>
                                <th style="height: 25px;">
                                    <div>{con}</div>
                                </th>
                            </tr>
                        </template>
                    </table>

JS

@track data;
getMergeLeads({Indexing:selectedIdsArray})
            .then(result => {
                var selectedIdRecords = result;
                this.data = selectedIdRecords;
                console.log('Get Merge Leads : '+JSON.stringify(this.data));
                
            })
            .catch(error => {
                this.error = error;
                console.log('Get Merge Leads error ===> '+error.body.message);
            });