• Gaurav Sinha 27
  • NEWBIE
  • 35 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 13
    Replies
Hi All veterans

Need one urgent help on how to call a javascript function on click of URL in lightning datatable record.

Thanks and regards
Gaurav Sinha
Hi All Veterans

I Have created a lightning data table as below:
component.set('v.mycolumns', [
         {label: 'Name', fieldName:'Name', type: 'url', sortable: true,
          typeAttributes: {label: { fieldName: 'Name' }}},
             {label: 'NON-LATIN NAME', fieldName: 'Non_LatinName__c', type: 'text', sortable: true},
             {label: 'ADDRESS', fieldName: 'Address__c', type: 'text', sortable: true},
             {label: 'City', fieldName: 'City__c', type: 'text', sortable: true},
             {label: 'City Region', fieldName: 'CityRegion__c', type: 'text', sortable: true},
             {label: 'State', fieldName: 'State__c', type: 'text', sortable: true},
             {label: 'Country', fieldName: 'Country__c', type: 'text', sortable: true},
             {label: 'MDCP Id', fieldName: 'MDCP_Id__c', type: 'text', sortable: true},
             {label: 'DUNS', fieldName: 'DUNS__c', type: 'text', sortable: true},
             {label: 'Domestic DUNS', fieldName: 'Domestic_DUNS__c', type: 'text', sortable: true},
             {label: 'Global DUNS', fieldName: 'Global_DUNS__c', type: 'text', sortable: true},
             {label: 'Tax ID', fieldName: 'Tax_ID__c', type: 'text', sortable: true},
             {label: 'Is Competitor', fieldName: 'Is_Competitor__c',type:'boolean', 
              "cellAttributes": {"iconName": { "fieldName": "IsCompetitor" },sortable: true}},
             {label: 'Out Of Business', fieldName: 'isOutOfBusiness__c',type:'boolean',
             "cellAttributes": {"iconName": { "fieldName": "OutOfBusiness" }, sortable: true}},
         ]);

I want to call an action on click of hyperlink created in column1. Need your expert advice for the same.
Thanks and regards
Gaurav Sinha
Hi All Veterans
I have written a component where I have to call other action on completion of the first action. Can anyone help me in this please as this is an urgent requirement. Below is the function:
SearchHelper: function(component, event,helper) {
		alert("search helper fired");
     	var country = component.find('country').get("v.value");
        var city = component.find('city').get("v.value");
        var street = component.find('street').get("v.value");
        var state = component.find('stateProvince').get("v.value");
        var postal = component.find('postalCode').get("v.value");
        var action = component.get("c.EMDMaddressDocLightning");
        action.setParams({
            'country':country,
            'city':city,
            'street' : street,
            'state' : state,
            'postalcode' : postal
        });
        action.setCallback(this, function(response){ 
            var state = response.getState();
            if (state === "SUCCESS") {
               var storeresponse= response.getReturnValue();
                alert("StoreResponse==>"+storeresponse);
                if (storeresponse.length==0){
                    component.set("v.NoResults", true);
                }
                if (storeresponse.length > 1){
                    component.set("v.ResultsFound", true);
                    component.set('v.AddDocColumns', [
                        {label: 'Street', type: 'text', value:'street'},
                        {label: 'City', type: 'text', value:'city'},
                        {label: 'State', type: 'text', value:'state'},
                        {label: 'Country', type: 'text', value:'country'},
                        {label: 'Postal Code', type: 'text', value:'postal'},
                    ]);
                    
                }
                if (storeresponse.length == 1){
                    storeResponse.forEach(function(record){ 
                        component.set("v.country", record.country);
                        component.set("v.city", record.city);
                        component.set("v.street", record.street);
                        component.set("v.stateProvince", record.state);
                        component.set("v.Postalcode", record.postalcode);
                });
                }
                component.set("v.AddressResult",storeresponse);
            }else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
                component.set("v.NoResults", true);
           }else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + 
                                    errors[0].message);
                    }
                }
                component.set("v.NoResults", true);
            }else {
                    alert("Unknown error");
                component.set("v.NoResults", true);
                }
        });
     //2nd action starts here...

     component.set('v.mycolumns', [
             {label: 'Name', fieldName: 'Name', type: 'url', sortable: true,
             typeAttributes: {label: { fieldName: 'Name' }, target: '#target'}},
             {label: 'NON-LATIN NAME', fieldName: 'Non_LatinName__c', type: 'text', sortable: true},
             {label: 'ADDRESS', fieldName: 'Address__c', type: 'text', sortable: true},
             {label: 'City', fieldName: 'City__c', type: 'text', sortable: true},
             {label: 'City Region', fieldName: 'CityRegion__c', type: 'text', sortable: true},
             {label: 'State', fieldName: 'State__c', type: 'text', sortable: true},
             {label: 'Country', fieldName: 'Country__c', type: 'text', sortable: true},
             {label: 'MDCP Id', fieldName: 'MDCP_Id__c', type: 'text', sortable: true},
             {label: 'DUNS', fieldName: 'DUNS__c', type: 'text', sortable: true},
             {label: 'Domestic DUNS', fieldName: 'Domestic_DUNS__c', type: 'text', sortable: true},
             {label: 'Global DUNS', fieldName: 'Global_DUNS__c', type: 'text', sortable: true},
             {label: 'Tax ID', fieldName: 'Tax_ID__c', type: 'text', sortable: true},
             {label: 'Is Competitor', fieldName: 'Is_Competitor__c',type:'boolean', 
              "cellAttributes": {"iconName": { "fieldName": "IsCompetitor" },sortable: true}},
             {label: 'Out Of Business', fieldName: 'isOutOfBusiness__c',type:'boolean',
             "cellAttributes": {"iconName": { "fieldName": "OutOfBusiness" }, sortable: true}},
         ]);
        // show spinner message
         component.find("Id_spinner").set("v.class" , 'slds-show');
        var action2 = component.get("c.GetAccounts");
        //var label= Label.DEAL_Query_Limit;
        var pageSize = component.get("v.pageSize");
        var pageNumber = component.get("v.pageNumber");
        var MDMquery='';
        var method='';
       	var city= component.find('city').get("v.value");
             if(city){
                 if(city.Length < 3){
                 alert("city: Please provide atleast 3 characters");
                 }             
             }
        var name= component.find('name').get("v.value");        
        var country= component.find('country').get("v.value");        
        var duns= component.find('duns').get("v.value");
        //var mdcpid= component.find('MDCPID').get("v.value");        
        var stateProvince= component.find('stateProvince').get("v.value");
        var postalCode= component.find('postalCode').get("v.value");
        var taxiD= component.find('taxiD').get("v.value");
    	var street= component.find('street').get("v.value");
        //var iscompetitor= component.find('IsCompetitor').get("v.value");      
        if(name || taxiD || city || stateProvince || country || postalcode)
        {            
            if(name)    MDMquery=MDMquery+'q=(+ organizationExtendedName:('+name+') OR organizationNonLatinExtendedName:('+name+') OR organizationReportingName:('+name+') OR organizationLegalName:('+name+') OR tradeStyleNames:('+name+'))';
            if(taxiD)   MDMquery=MDMquery+' AND taxIds:(+'+taxiD +')';
            if(city)    MDMquery=MDMquery+' AND (+ latinCity:('+city+') OR cityRegion:(+'+city+'))';
            if(stateProvince)   MDMquery=MDMquery+' AND state:(+'+stateProvince+')'; 
            if(country)
                 {            
                    if(country.includes(" ")){
                           MDMquery=MDMquery+' AND countryName:(+"'+country+'")';  
                    }else{
                           MDMquery=MDMquery+' AND countryName:(+'+country+')';  
                    }
                }        
            if(postalCode) MDMquery=MDMquery+' AND postalCode:(+'+postalCode+')';            
            MDMquery=MDMquery+' LIMIT '+ '200' +' OFFSET '+ pageSize*pageNumber + '';
                //' AND isOutOfBusiness:(+ false)'+      
            MDMquery=MDMquery.replace('&',' ');
            method='MDMSearch';
             }else if(duns)
             {
             	method='getDetailbyDuns';
             }else if(mdcpid)
             {
             	method='getDetailbyOrgId';
             }
    if(country || street || city || stateProvince || postalcode){
    	component.set("v.AddressDoc",true);
    }
        action2.setParams({
            'Query':MDMquery,
            'SearchMethod':method,
            'pageSize' : pageSize,
            'pageNumber' : pageNumber
        });
        action2.setCallback(this, function(response) {            
           // hide spinner when response coming from server 
            component.find("Id_spinner").set("v.class" , 'slds-hide');                    
            var state = response.getState();
            if (state === "SUCCESS") {                
             var pageSize = component.get("v.pageSize");
                // hold all the records into an attribute named "AccountData"
                component.set('v.AccountData', response.getReturnValue());
                // get size of all the records and then hold into an attribute "TotalNumberOfRecord"
                component.set("v.TotalNumberOfRecord", component.get("v.AccountData").length);
                // set star as 0
                component.set("v.startPage",0);
                
                component.set("v.endPage",pageSize-1);
                var PaginationList = [];
                for(var i=0; i< pageSize; i++){
                    if(component.get("v.AccountData").length> i)
                        PaginationList.push(response.getReturnValue()[i]);    
                }
                component.set('v.searchResult', PaginationList);
                component.set('v.isSending',false);
				component.find("accordion").set('v.activeSectionName', 'Search Results');
             var storeResponse = response.getReturnValue();
             storeResponse.forEach(function(record){ 
                    if(typeof record.Id === true || typeof record.Id === false){                         
                        // https://www.lightningdesignsystem.com/icons/#utility 
                        if(record.Is_Competitor__c=== true){
                            record.IsCompetitor = 'utility:check';
                        }
             			else if(record.isOutOfBusiness__c=== true){
                            record.OutOfBusiness = 'utility:check';
                        }                       
                    }
                });
             //alert('storeResponse'+JSON.stringify(storeResponse));
                // if result size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                }else if (storeResponse.length >= 200) {
                    component.set("v.Notification", true);
                } else {
                    component.set("v.Message", false);
                    component.set("v.Notification", false);
                }                
                // set numberOfRecord attribute value with length of return value from server

                helper.sortData(component, component.get("v.sortedBy"), component.get("v.sortedDirection"));
				//var refreshview = $A.get('e.force:refreshView').fire();                
            }else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }

        });        
        $A.enqueueAction(action);
        $A.enqueueAction(action2);
    },

 
Hi All Veterans

I have created a component to search account data from external server. We have two of the search criterias as Country and State. Country is a picklist and state we have to create a autocomplete component based on the country selected, i am getting the country and corresponding state values from the apex controller in doinit method and storing it in attribute countrypicklistvalue and statepicklistvalue respectively. can anyone help me in creating the autocomplete ui:inputtext field please.
Thanks in advance

Gaurav Sinha
Hi all Veterans
I have a lightning account search page, where one of the search criteria is Country(Picklist). I am populating country picklist value from apex class. There is one more field called State. Now the requirement is that the Country picklist value should be set default to the logged in user's country and while we type in state field its should show option to autocomplete the field. Lets say selected country is India, so when we type 'ka' in state field it should show options starting with 'ka ' for rg. Karnataka and so on. Any help will be highly appreciated as its an urgent requirement.

Thanks in Advance
Gaurav Sinha
Hi All Veterans

Is there any way we can do Fuzzy match of strings in salesforce, lets say we want to compare the value of first name of a contact to find the duplicate based on fuzzy match. 

Thanks and regards
Gaurav Sinha
Hi all Veteran

We have a requirement wherein we have to create a lightning page where we have to search account data from external server. attached is the screenshot for the page layout. can anyone help me in that please.
User-added image
Hi All Veterans
We have a requirement wherein we have to write a trigger on contact after update. There will be a field called IsDeleted in contacts, when that field will be selected the contact will automatically get associated with a private account. Now the challenge is we have to create the  private account dynamically. Before associating the contact we have to check if that pfivate account contains 10000 contacts if yes then create a new private account and associate that contact with the newly created private account else with the previous account, this process will continue.

Thanks in advance...:)
HI all
Can anyone help me in writing a test class for below class.
Public Class QuotationController
{
   
    Public quoteInfo Quote {get;set;}     
    private final Quotation__c QuotationRec;

    public QuotationController(ApexPages.StandardController controller) {
        QuotationRec=(Quotation__c)controller.getRecord();
        Quotation__c QuotationRec=getQuotationRec(QuotationRec.Id);
        getQuote(QuotationRec);
    }
    
    Public quoteInfo getQuote(Quotation__c Quotation)
    {
        Query__c Query=[Select Id,Name,Client__c,Destination__c,Duration__c,Hotel_Category__c,Meal_Plan__c,Source__c from Query__c where Id=:Quotation.Query__c];
        
        Quote=New quoteInfo();
        Quote.QuoteNumber=Quotation.Name;
        Quote.Client=getContactInfo(Query.Client__c);
        Quote.QuotationValidTill=Quotation.Quotation_Valid_Till__c; 
        Quote.companyinfoRec=getcompanyInfo(Quotation.Id);
        Quote.hotelInfoList=gethotelInfo(Quotation.Id);     
        Quote.excursionInfoList=getexcursionInfo(Quotation.Id); 
        Quote.source=getDestinationInfo(Query.Source__c);
        Quote.destination=getDestinationInfo(Query.Destination__c); 
        Quote.HotelCharge=Quotation.Hotel_Charge__c;    
        Quote.ExcursionCharge=Quotation.Excursion_Charge__c;    
        Quote.GST=Quotation.GST__c; 
        Quote.PackageCost=Quotation.Package_Cost__c;
        Quote.Markup=Quotation.Markup__c;
        Quote.Itinerary=Quotation.Itinerary__c;     
        Quote.ProposedByName=Quotation.Createdby.Name;          
        System.debug('<===Quote==>'+Quote);
        return Quote;
    }    
    
    Public Quotation__c getQuotationRec(String QuotationId)
    {
        Quotation__c Q=[SELECT Createdby.Name,Excursion_Charge__c,GST__c,Hotel_Charge__c,Id,Itinerary__c,Markup__c,Name,Package_Cost__c,Query__c,Quotation_Valid_Till__c,Quoted_By__c,Status__c FROM Quotation__c Where Id=:QuotationId];
        return Q;
    }    
    
    Public Contact getContactInfo(String ContactId)
    {
       System.debug('<==ContactId==>'+ContactId);
        Contact C=[Select Id,Name,Email,MailingStreet,MailingCity,MailingPostalCode ,MailingCountry,HomePhone  From Contact Where Id=:ContactId];
        return C;
    }   
    
    Public Destination__c getDestinationInfo(String DestinationId)
    {
        Destination__c D=[Select Id,Name,Country__c From Destination__c Where Id=:DestinationId];
        return D;
    }      
    
    
    Public companyInfo getcompanyInfo(String QuoteId)
    {
        Company_Information__c CompInf=Company_Information__c.getInstance(UserInfo.getOrganizationId());
        companyInfo CI=New companyInfo();       
        CI.Name=CompInf.Name;
        CI.Address=CompInf.Address__c;
        CI.Email=CompInf.Email__c;
        CI.Phone=CompInf.Mobile__c;
        CI.Website=CompInf.Website__c;
        CI.Follow=CompInf.Follow_on_Facebook__c;        
        return CI;
    }
    
    Public List<hotelInfo> gethotelInfo(String QuoteId)
    {
        List<hotelInfo>hotelInfoList=New List<hotelInfo>();
        List<Hotel__c>HotelList=New List<Hotel__c>();   
        Map<Id,Hotel_Information__c>HotelInfoMap=New Map<Id,Hotel_Information__c>();        
        Set<Id>HotelIds=New Set<Id>();
        
        List<Hotel_Information__c>HIlist=[Select ID,Hotel__c,Hotel_Charge__c,Request__c,Payable_Amount__c from Hotel_Information__c where Quotation__c=:QuoteId];
        for(Hotel_Information__c E:HIlist )
        {
            HotelInfoMap.put(E.Hotel__c,E);
            HotelIds.add(E.Hotel__c);
        }
        
        HotelList=[Select Id,Name,Rate__c,Category__c,City__c,Country__c,State__c from Hotel__c where id=:HotelIds];
        
        for(Hotel__c E:HotelList)
        {
            Hotel_Information__c HIN=HotelInfoMap.get(E.Id);
            hotelInfo HI=New hotelInfo();
            HI.Name=E.Name;
            HI.Category=E.Category__c;  
            HI.City=E.City__c;  
            HI.Country=E.Country__c;                
            HI.Rate=E.Rate__c;  
            HI.NumberofNights=HIN.Request__c;
            HI.Amount=HIN.Payable_Amount__c;            
            hotelInfoList.add(HI);          
        }
                
        return hotelInfoList;     
    }       
    
    Public List<excursionInfo> getexcursionInfo(String QuoteId)
    {
        List<excursionInfo>excursionInfoList=New List<excursionInfo>();
        List<Excursions__c>ExcursionsList=New List<Excursions__c>();    
        Map<Id,Excursion_INformation__c>ExcursionMap=New Map<Id,Excursion_INformation__c>();        
        Set<Id>ExcursionIds=New Set<Id>();
        
        List<Excursion_INformation__c>EIlist=[Select ID,Excursion__c,Excursion_Charge__c,Number_of_Persons__c,Payable_Amount__c from Excursion_INformation__c where Quotation__c=:QuoteId];
        for(Excursion_INformation__c E:EIlist )
        {
            ExcursionMap.put(E.Excursion__c,E);
            ExcursionIds.add(E.Excursion__c);
        }
        
        ExcursionsList=[Select Id,Name,Rate__c from Excursions__c where id=:ExcursionIds];
        
        for(Excursions__c E:ExcursionsList)
        {
            Excursion_INformation__c EIN=ExcursionMap.get(E.Id);
            excursionInfo EI=New excursionInfo();
            EI.Name=E.Name;
            EI.Rate=E.Rate__c;      
            EI.NumberofPerson=EIN.Number_of_Persons__c;   
            EI.Amount=EIN.Payable_Amount__c;
            excursionInfoList.add(EI);          
        }
                
        return excursionInfoList;     
    }       


    Public class quoteInfo
    {
        public string QuoteNumber {get;set;}
        public contact Client {get;set;}
        public Date QuotationValidTill {get;set;}       
        public companyInfo companyinfoRec {get;set;}
        public list<hotelInfo> hotelInfoList {get;set;}
        public list<excursionInfo> excursionInfoList {get;set;}
        public Destination__c source {get;set;}
        public Destination__c destination {get;set;}
        public Decimal HotelCharge {get;set;}
        public Decimal ExcursionCharge {get;set;}
        public Decimal GST {get;set;}
        public Decimal PackageCost {get;set;}   
        public Decimal Markup {get;set;}    
        public string Itinerary {get;set;}     
        public string ProposedByName {get;set;}                       
    }


    Public class companyInfo
    {
        public string Name {get;set;}
        public string Address {get;set;}
        public string Email {get;set;}
        public string Phone {get;set;}
        public string Website {get;set;}
        public string Follow{get;set;}        
    }
    
    Public class hotelInfo
    {
        public string Name {get;set;}
        public string Category {get;set;}
        public string City {get;set;}
        public string Country {get;set;}        
        public Decimal Rate {get;set;}
        public Decimal NumberofNights {get;set;}
        public Decimal Amount {get;set;}
    }       
    
    Public class excursionInfo
    {
        public string Name {get;set;}
        public Decimal Rate {get;set;}
        public Decimal NumberofPerson {get;set;}
        public Decimal Amount {get;set;}
    } 
    
             
}
Hi all Veterans
We have a requirement wherein we need to call a class which performs a callout to sync account with external system inside a batch apex and after the sync is success we need to update a particular field in the synced account. Can anyone help me to achieve this?
Thanks
Gaurav Sinha
Hi all Veterans
We have a requirement wherein we have to sync the account record with an external server. In account there would be a checkbox to select to sync, if the checkbox will be selected the sync should be processed asynchronously and after the sync is successfully done the checkbox should be set to false. I would appreciate if someone can help me with the complete code.
Thanks in advance.
Below is the class to merge contacts based on merge criteria defined. Can someone help me in writing a test class for the same. Need to deploy it by EOD.
global class ContactMergeBatch implements Database.Batchable<AggregateResult>, Database.Stateful
{
    private String query;
    private String dupBy;
    private String pastNDays; 
    private Integer BatchSize;  
    private Set<ID> accIds;
    private Set<String> previousQualifiedIds = new Set<String>();  
    private Set<String> skipEmails;   
    private List<String> recipientEmails;      
    private String CustomerRTId=Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Customer').getRecordTypeId();   
    private String ConsumerRTId=Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Consumer').getRecordTypeId(); 
    private Map<String,ContactMergeWrappper> mergeDupMap;  
    private Map<String,DateTime> createdDateMap;    
    private List<ContactMergeWrappper>MergeStatusList;   
    Private Integer MergeCount;   

    
    global ContactMergeBatch(String pnds,String db,Set<String> pqIds,Map<String,DateTime>cdbm)
    {
        dupBy=db;
        pastNDays=pnds; 
        previousQualifiedIds=pqIds;
        createdDateMap=cdbm; 
              
        mergeDupMap = new Map<String,ContactMergeWrappper>();
        MergeStatusList=New List<ContactMergeWrappper>();        
        
        EMDM_Schedule_Job_Config__c config= EMDM_Schedule_Job_Config__c.getvalues('Contact Merge Batch');
        pastNDays=config.Last_N_Days__c; 
        BatchSize=Integer.Valueof(config.BatchLoad__c); 
        
        skipEmails = new Set<String>(config.Skip_Email_List__c.split(','));
        recipientEmails= new List<String>(config.Confirmation_Recipient__c.split(','));        
                                           
        if(dupBy == 'PersonId') query = 'Select AccountId from Contact where AccountId !=null and CreatedDate = LAST_N_DAYS:'+pastNDays+' and ( RecordTypeId=\''+CustomerRTId+'\' OR RecordTypeId=\''+ConsumerRTId+'\') and IsActive__c=true GROUP BY AccountId';
        else 
        {
            if(previousQualifiedIds.size()>0)
            {
                String pIds = String.join(new List<String>(previousQualifiedIds), '\',\'');
                pIds='(\''+pIds+'\')';
                System.debug('pIds==>'+pIds);
                query = 'Select AccountId from Contact where ( AccountId !=null and CreatedDate = LAST_N_DAYS:'+pastNDays+' and ( RecordTypeId=\''+CustomerRTId+'\' OR RecordTypeId=\''+ConsumerRTId+'\') and IsActive__c=true ) OR AccountId IN '+pIds+' GROUP BY AccountId';
            }
            else
            {
                query = 'Select AccountId from Contact where  AccountId !=null and CreatedDate = LAST_N_DAYS:'+pastNDays+' and ( RecordTypeId=\''+CustomerRTId+'\' OR RecordTypeId=\''+ConsumerRTId+'\') and IsActive__c=true GROUP BY AccountId';
            }   
        }
        
        System.debug('mergeBy==>'+dupBy+' pastNDays==>'+pastNDays+ ' query==>'+query);  
    }
        
    //The batch job starts  if(a!=null) 
    global Iterable<AggregateResult> start(Database.BatchableContext bc)
    {
        return new AggregateResultIterable(query);
    } 
    
    
    global void execute(Database.BatchableContext bc, List<sObject> scope)
    {   
        accIds=new Set<ID>();
        for(sObject a : scope) accIds.add((Id)a.get('AccountId'));
        System.debug('accIds==>'+accIds.size()); 
               
        List<Contact>QualifiedContacts=[SELECT id,Accountid,Salutation,FirstName,Second_Name__c,LastName,Phone,Separation_Contact__c,Preferred_Method_of_Contact__c,Preferred_Language__c,IsActive__c,Service_Sales_Contact__c,Phonetic_First_Name__c,Phonetic_Second_Name__c ,Phonetic_Last_Name__c ,First_Name_Local__c,Second_Name_Local__c,Last_Name_Local__c,Title,Standardized_Title__c,Phone__c,Work_Phone_Extension__c,MobilePhone,HomePhone,Email,Key_Contact_to__c,DoNotCall,Left_Company__c,Isolation_Status__c,Isolation_Status_Date__c,GDPR_Governed__c,Isolation_Comment__c,Teleoptin_Required__c,Preferred_Subjects__c,Job_Seniority__c,Lead_Source_Most_Recent__c,Job_Responsibilities__c,MDM_ContactSync_Status__c,Suppress_Marketing__c,Suppression_Start_Date__c,Suppression_End_Date__c,Description,Job_Role__c,Business_Function__c,Industry__c,BU_Lead__c, Lead_Source_Original1__c, HP_Customer_Self_Reported__c, MailingCity, MailingState, MailingCountry, MailingPostalCode, MailingStreet, Fax,MDM_Person_ID__c,MDCP_Last_Sync_Date__c,LeadSource,SFDC_MDCP_Batch_Sync_Flag__c,CreatedDate, RecordTypeId, LastModifiedDate,Isolation_Reason__c,  MailingCity__c, MailingCountry__c, MailingPostalCode__c, MailingState__c, MailingStreet__c, Telephone_Access_Code__c, Service_Delivery_Email_Opt_In__c, Email_Quality_Survey_Opt_In__c, Phone_Quality_Survey_Opt_In__c, Department, Lead_Source__c,Case_Closure_Notification_Opt_In__c, Alternate_Preferred_Customer_Language__c, Part_Delivered_Notification_Opt_In__c, VisitOps__LinkedInUrl__c, Previous_MDCP_Contact_Relationship__c, Preferred_Language_Code__c,  Preferred_Customer_Language__c, Location_ID__c, Contact_External_Id__c, Customer_Division__c, DPlus_Company_Reference__c, SourceSystemContactID__c FROM Contact where AccountId=:accIds and IsActive__c=true AND EMAIL NOT IN :skipEmails ORDER BY CreatedDate DESC];
        System.debug('QualifiedContacts==>'+QualifiedContacts);  
         
        Map<ID,List<contact>> SegContactMap  = new Map<ID,List<contact>>();
        Map<String,ContactMergeWrappper> DupMap = new Map<string,ContactMergeWrappper>();
     
        String dupKey;
        //Segregating All Contacts by Account
        for(contact c :QualifiedContacts)
        {
            list<contact> clist=new list<contact>();  
            if(SegContactMap.get(c.accountid)!=null)
            {
                clist  = SegContactMap.get(c.accountid);
            }
            clist.add(c);
            SegContactMap.put(c.accountid,clist);
        }
        System.debug('SegContactMap==>'+SegContactMap); 
        
        //Finding Duplicate based on Filter Passed
        Boolean validKey = true;
        for(Id accid : SegContactMap.keySet())
        {
            for(Contact con : SegContactMap.get(accid))
            {
                validKey = true;
                if(DupBy=='LastNameEmail') 
                {   
                    if(String.isBlank(con.Email))  validKey = false;
                    dupKey = con.AccountId+con.LastName+con.Email; 
                }
                else 
                {
                    if(String.isBlank(con.MDM_Person_ID__c))  validKey = false;
                    dupKey = con.AccountId+con.MDM_Person_ID__c; 
                }
                System.debug('dupKey ===>'+dupKey +' ==>'+DupBy); 
                if(DupMap.get(dupKey)==null && validKey)
                {
                    list<Contact> Dlist = new list<Contact>();
                    ContactMergeWrappper W = new ContactMergeWrappper(con,Dlist,'Processing');
                    DupMap.put(dupKey,W);
                }
                else if(DupMap.get(dupKey)!=null && validKey)
                { 
                    ContactMergeWrappper W=DupMap.get(dupKey);  
                    
                    DateTime RTCD,CSCD;
                    RTCD = createdDateMap.get(con.Id) !=null? createdDateMap.get(con.Id):con.CreatedDate;
                    CSCD = createdDateMap.get(W.Survivor.Id) !=null? createdDateMap.get(W.Survivor.Id):W.Survivor.CreatedDate;
                    
                    if(RTCD >= CSCD)
                    {
                        W.donors.add(W.Survivor);
                        W.Survivor=con;
                    }
                    else
                    {
                        W.donors.add(con);  
                    }
                    DupMap.put(dupKey,W);              
                }
            }
        }        
        //Filter out records with no Donors
        System.debug('DupMap==>'+DupMap.size()+' ===>'+DupMap); 
        mergeDupMap=New Map<String,ContactMergeWrappper>();
        for(String key : DupMap.keySet())
        {
            ContactMergeWrappper W=DupMap.get(key);
            if(W.donors.Size()>0)
            {
                mergeDupMap.put(W.Survivor.Id,W);
                System.debug('The previousQualifiedIds 2' + previousQualifiedIds);
                previousQualifiedIds.add(W.Survivor.AccountId);  
                createdDateMap.put(W.Survivor.Id,W.Survivor.CreatedDate);               
            }
        }
        System.debug('mergeDupMap==>'+mergeDupMap.size()+' ===>'+mergeDupMap); 
       
        //Merging the Qualified records one by one
        for(ID DI:mergeDupMap.keyset())
        {
            ContactMergeWrappper MergeResult=ContactMergeHelper.ProcessMerge(mergeDupMap.get(DI)) ;             
            MergeStatusList.add(MergeResult);
            System.debug('MergeResult==>'+MergeResult);             
        }
                                        
    }     
    
    // The batch job finishes
    global void finish(Database.BatchableContext bc)
    { 
        String mergeText = 'Donor PersonId,Donor Email,Donor FirstName,Donor LastName,Donor Id,Donor CreatedDate,Survivor PersonId,Survivor Email,Survivor FirstName,Survivor LastName,Survivor Id,Survivor CreatedDate,Status' + '\n';
        Integer ErorCount = 0;
        for(ContactMergeWrappper mw:MergeStatusList)
        {
            List<Contact>DonorList = mw.Donors; 
            Contact Survivor = mw.Survivor; 
            if(mw.Status=='Processed')
            {
                for(Contact donor:DonorList)
                {
                    if(mw.MergeStatusMap.get(donor.Id) !='Record Merged Sucessfully'){
                        mergeText += donor.MDM_Person_ID__c+ ','  +donor.Email+ ','+donor.FirstName+ ',' +donor.LastName+ ','  +donor.Id+ ','+donor.CreatedDate+ ','  +Survivor.MDM_Person_ID__c+ ',' +Survivor.Email+ ','  +Survivor.FirstName+ ','  +Survivor.LastName+ ','  +Survivor.Id+ ','  +Survivor.CreatedDate+ ','  +mw.MergeStatusMap.get(donor.Id)  + '\n';
                        ErorCount++; 
                    }
            //DonorList.clear();            
                    MergeCount= mw.MergeStatusMap.size(); 
                }
            }  
        }      
        mergeText = mergeText.substring(0, mergeText.length() -1 );
        
        If(ErorCount>0){ 
             Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
            blob csvBlob = Blob.valueOf(mergeText);
            DateTime d = Date.Today() ; 
            String dateStr =  d.format('dd-MM-yyyy') ;        
            string csvname= 'Contact_Merge_Status_BY_'+dupBy+'  '+dateStr+'.csv';
            csvAttc.setFileName(csvname);
            csvAttc.setBody(csvBlob);
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = recipientEmails;
            message.subject = 'Contact merge Error report '+String.valueof(Date.Today());
          //message.plainTextBody = 'Hi,  \n  Please Find the Status of Merge Performed on'+String.valueof(Date.Today());
            message.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
            String bodyStart='<html><body><h3>Contact Merge Failure Report:</h3> <table align="left" border="1" cellpadding="1" cellspacing="1" style="width: 500px;"><tbody><tr><td>Operation</td><td>Contact Merge</td></tr><tr><td>Status</td><td>Merge Failed</td>';
            String BodyStarttime='</td></tr><tr><td>Time Processed</td><td>';
            String NoOfRecordProssced='</td></tr><tr><td>Number of Duplicate records Processed</td><td>';
            String errorCounts='</td></tr><tr><td>Number of records Faield to Merge</td><td>';
            String BodyTail='</td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>&nbsp;<p>&nbsp;</p><p>Thank You</p><p>Contact Merging Team</p><body></html>';       
            String HTMLBody=bodyStart+NoOfRecordProssced+MergeCount+errorCounts+ErorCount+BodyStarttime+string.valueof(system.now())+BodyTail;
            message.setHtmlBody(HTMLBody);
            Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message};
            Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);

        }
        if(dupBy=='PersonId') Id JobId = Database.executeBatch(new ContactMergeBatch(pastNDays,'LastNameEmail',previousQualifiedIds,createdDateMap),BatchSize);

    }
}
hi, I need to create a custom VF page to show account hierarchy. Can someone help me with the same as its urgent.
Hi All veterans

Need one urgent help on how to call a javascript function on click of URL in lightning datatable record.

Thanks and regards
Gaurav Sinha
Hi All Veterans
I have written a component where I have to call other action on completion of the first action. Can anyone help me in this please as this is an urgent requirement. Below is the function:
SearchHelper: function(component, event,helper) {
		alert("search helper fired");
     	var country = component.find('country').get("v.value");
        var city = component.find('city').get("v.value");
        var street = component.find('street').get("v.value");
        var state = component.find('stateProvince').get("v.value");
        var postal = component.find('postalCode').get("v.value");
        var action = component.get("c.EMDMaddressDocLightning");
        action.setParams({
            'country':country,
            'city':city,
            'street' : street,
            'state' : state,
            'postalcode' : postal
        });
        action.setCallback(this, function(response){ 
            var state = response.getState();
            if (state === "SUCCESS") {
               var storeresponse= response.getReturnValue();
                alert("StoreResponse==>"+storeresponse);
                if (storeresponse.length==0){
                    component.set("v.NoResults", true);
                }
                if (storeresponse.length > 1){
                    component.set("v.ResultsFound", true);
                    component.set('v.AddDocColumns', [
                        {label: 'Street', type: 'text', value:'street'},
                        {label: 'City', type: 'text', value:'city'},
                        {label: 'State', type: 'text', value:'state'},
                        {label: 'Country', type: 'text', value:'country'},
                        {label: 'Postal Code', type: 'text', value:'postal'},
                    ]);
                    
                }
                if (storeresponse.length == 1){
                    storeResponse.forEach(function(record){ 
                        component.set("v.country", record.country);
                        component.set("v.city", record.city);
                        component.set("v.street", record.street);
                        component.set("v.stateProvince", record.state);
                        component.set("v.Postalcode", record.postalcode);
                });
                }
                component.set("v.AddressResult",storeresponse);
            }else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
                component.set("v.NoResults", true);
           }else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + 
                                    errors[0].message);
                    }
                }
                component.set("v.NoResults", true);
            }else {
                    alert("Unknown error");
                component.set("v.NoResults", true);
                }
        });
     //2nd action starts here...

     component.set('v.mycolumns', [
             {label: 'Name', fieldName: 'Name', type: 'url', sortable: true,
             typeAttributes: {label: { fieldName: 'Name' }, target: '#target'}},
             {label: 'NON-LATIN NAME', fieldName: 'Non_LatinName__c', type: 'text', sortable: true},
             {label: 'ADDRESS', fieldName: 'Address__c', type: 'text', sortable: true},
             {label: 'City', fieldName: 'City__c', type: 'text', sortable: true},
             {label: 'City Region', fieldName: 'CityRegion__c', type: 'text', sortable: true},
             {label: 'State', fieldName: 'State__c', type: 'text', sortable: true},
             {label: 'Country', fieldName: 'Country__c', type: 'text', sortable: true},
             {label: 'MDCP Id', fieldName: 'MDCP_Id__c', type: 'text', sortable: true},
             {label: 'DUNS', fieldName: 'DUNS__c', type: 'text', sortable: true},
             {label: 'Domestic DUNS', fieldName: 'Domestic_DUNS__c', type: 'text', sortable: true},
             {label: 'Global DUNS', fieldName: 'Global_DUNS__c', type: 'text', sortable: true},
             {label: 'Tax ID', fieldName: 'Tax_ID__c', type: 'text', sortable: true},
             {label: 'Is Competitor', fieldName: 'Is_Competitor__c',type:'boolean', 
              "cellAttributes": {"iconName": { "fieldName": "IsCompetitor" },sortable: true}},
             {label: 'Out Of Business', fieldName: 'isOutOfBusiness__c',type:'boolean',
             "cellAttributes": {"iconName": { "fieldName": "OutOfBusiness" }, sortable: true}},
         ]);
        // show spinner message
         component.find("Id_spinner").set("v.class" , 'slds-show');
        var action2 = component.get("c.GetAccounts");
        //var label= Label.DEAL_Query_Limit;
        var pageSize = component.get("v.pageSize");
        var pageNumber = component.get("v.pageNumber");
        var MDMquery='';
        var method='';
       	var city= component.find('city').get("v.value");
             if(city){
                 if(city.Length < 3){
                 alert("city: Please provide atleast 3 characters");
                 }             
             }
        var name= component.find('name').get("v.value");        
        var country= component.find('country').get("v.value");        
        var duns= component.find('duns').get("v.value");
        //var mdcpid= component.find('MDCPID').get("v.value");        
        var stateProvince= component.find('stateProvince').get("v.value");
        var postalCode= component.find('postalCode').get("v.value");
        var taxiD= component.find('taxiD').get("v.value");
    	var street= component.find('street').get("v.value");
        //var iscompetitor= component.find('IsCompetitor').get("v.value");      
        if(name || taxiD || city || stateProvince || country || postalcode)
        {            
            if(name)    MDMquery=MDMquery+'q=(+ organizationExtendedName:('+name+') OR organizationNonLatinExtendedName:('+name+') OR organizationReportingName:('+name+') OR organizationLegalName:('+name+') OR tradeStyleNames:('+name+'))';
            if(taxiD)   MDMquery=MDMquery+' AND taxIds:(+'+taxiD +')';
            if(city)    MDMquery=MDMquery+' AND (+ latinCity:('+city+') OR cityRegion:(+'+city+'))';
            if(stateProvince)   MDMquery=MDMquery+' AND state:(+'+stateProvince+')'; 
            if(country)
                 {            
                    if(country.includes(" ")){
                           MDMquery=MDMquery+' AND countryName:(+"'+country+'")';  
                    }else{
                           MDMquery=MDMquery+' AND countryName:(+'+country+')';  
                    }
                }        
            if(postalCode) MDMquery=MDMquery+' AND postalCode:(+'+postalCode+')';            
            MDMquery=MDMquery+' LIMIT '+ '200' +' OFFSET '+ pageSize*pageNumber + '';
                //' AND isOutOfBusiness:(+ false)'+      
            MDMquery=MDMquery.replace('&',' ');
            method='MDMSearch';
             }else if(duns)
             {
             	method='getDetailbyDuns';
             }else if(mdcpid)
             {
             	method='getDetailbyOrgId';
             }
    if(country || street || city || stateProvince || postalcode){
    	component.set("v.AddressDoc",true);
    }
        action2.setParams({
            'Query':MDMquery,
            'SearchMethod':method,
            'pageSize' : pageSize,
            'pageNumber' : pageNumber
        });
        action2.setCallback(this, function(response) {            
           // hide spinner when response coming from server 
            component.find("Id_spinner").set("v.class" , 'slds-hide');                    
            var state = response.getState();
            if (state === "SUCCESS") {                
             var pageSize = component.get("v.pageSize");
                // hold all the records into an attribute named "AccountData"
                component.set('v.AccountData', response.getReturnValue());
                // get size of all the records and then hold into an attribute "TotalNumberOfRecord"
                component.set("v.TotalNumberOfRecord", component.get("v.AccountData").length);
                // set star as 0
                component.set("v.startPage",0);
                
                component.set("v.endPage",pageSize-1);
                var PaginationList = [];
                for(var i=0; i< pageSize; i++){
                    if(component.get("v.AccountData").length> i)
                        PaginationList.push(response.getReturnValue()[i]);    
                }
                component.set('v.searchResult', PaginationList);
                component.set('v.isSending',false);
				component.find("accordion").set('v.activeSectionName', 'Search Results');
             var storeResponse = response.getReturnValue();
             storeResponse.forEach(function(record){ 
                    if(typeof record.Id === true || typeof record.Id === false){                         
                        // https://www.lightningdesignsystem.com/icons/#utility 
                        if(record.Is_Competitor__c=== true){
                            record.IsCompetitor = 'utility:check';
                        }
             			else if(record.isOutOfBusiness__c=== true){
                            record.OutOfBusiness = 'utility:check';
                        }                       
                    }
                });
             //alert('storeResponse'+JSON.stringify(storeResponse));
                // if result size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                }else if (storeResponse.length >= 200) {
                    component.set("v.Notification", true);
                } else {
                    component.set("v.Message", false);
                    component.set("v.Notification", false);
                }                
                // set numberOfRecord attribute value with length of return value from server

                helper.sortData(component, component.get("v.sortedBy"), component.get("v.sortedDirection"));
				//var refreshview = $A.get('e.force:refreshView').fire();                
            }else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }

        });        
        $A.enqueueAction(action);
        $A.enqueueAction(action2);
    },

 
Hi All Veterans
We have a requirement wherein we have to write a trigger on contact after update. There will be a field called IsDeleted in contacts, when that field will be selected the contact will automatically get associated with a private account. Now the challenge is we have to create the  private account dynamically. Before associating the contact we have to check if that pfivate account contains 10000 contacts if yes then create a new private account and associate that contact with the newly created private account else with the previous account, this process will continue.

Thanks in advance...:)
Hello,

I'm trying display a message error on lightning component when i get some error on my apex class, like when my select returns zero records.Or my field doesent have the rigth formatt.

Please, can anyone could help me?

 
My requirement is 

I need to show the Account hierarchy in custom vf page as same as standard like

In Account object, we have created on the field which is existing Account (lookUp).
if any Account is linked with this account then we need to show the All child account linked to that particular acc in VF page.
Account Name(Parent Account)    Type(Child Account)   Account Owner(Child Acc Owner)
TRTest                                            Industry                      prem
TrTest1                                           other                           karan 
And finally I want to add this page on Account Layout that user can see his/her Linked Account Hierarchy Wise..

Need Urgent Help...

 
I can't find Dev Hub in my org's Setup search.