public without sharing class SearchLeadController { public String searchKeyWord{set;get;} public String staticResource {get; set;} public String leadAWSIds {set;get;} public String leadsInfo {set;get;} public String PIPL_Search_Contact_Label{set;get;} public SearchLeadController() { // String accountId = ApexPages.currentPage().getParameters().get('accountId'); searchKeyWord = ApexPages.currentPage().getParameters().get('searchLeadKeyWord');//add by Li Jun 20220321 PIPL_Search_Contact_Label = Label.PIPL_Search_Contact_Label; //1. Query Contact by accountId List leadList = new List(); // system.debug('Account Id from Front-end:'+accountId); // if(String.isNotBlank(accountId) && String.isNotEmpty(accountId)){ // leadList = new List([select Id,AWS_Data_Id__c from Lead where AccountId=:accountId and AWS_Data_Id__c!='']); // } leadList = new List([select Id,AWS_Data_Id__c from Lead where AWS_Data_Id__c!='']); //2. Prepare the Contact Info Map awsIdToLeadMap = new Map(); List leAWSIds = new List(); for(Lead le:leadList){ leAWSIds.add(le.AWS_Data_Id__c); awsIdToLeadMap.put(le.AWS_Data_Id__c,le); } leadsInfo = JSON.serialize(awsIdToLeadMap); leadAWSIds = JSON.serialize(leAWSIds); staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Lead')); } @RemoteAction public static Response searchLeads(String awsLeadIds) { Response resp = new Response(); resp.status = 'fail'; if(String.isBlank(awsLeadIds)||String.isEmpty(awsLeadIds)){ return resp; } List awsDataIds = (List) JSON.deserialize(awsLeadIds, List.class); Map awsIdToLeadMapTemp = new Map(); List leadListTemp = new List([select Id,AWS_Data_Id__c from Lead where AWS_Data_Id__c in:awsDataIds]); for(Lead le:leadListTemp){ awsIdToLeadMapTemp.put(le.AWS_Data_Id__c,le); } if(awsIdToLeadMapTemp.keySet().size()>0){ resp.status = 'success'; resp.message = JSON.serialize(awsIdToLeadMapTemp); } return resp; } public class Response{ public String message{set;get;} public String status{set;get;} } }