SHARE
TWEET

Untitled

a guest Jul 21st, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ({
  2. doInit : function(component, event, helper) {    
  3.     console.log('v.recordID: '+component.get("v.recordId"));
  4.     console.log('v.currentSObjectName: '+component.get("v.sObjectName"));
  5.  
  6.     helper.getDuns(component);
  7.     component.set("v.showContacts", component.find("checkboxContacts").get("v.value"));
  8.     component.set("v.showLeads", component.find("checkboxLeads").get("v.value"));
  9.  
  10.  
  11. },  })
  12.      
  13. ({
  14. getDuns:  function(component) {  
  15.     var action = component.get("c.getDunsByRecordId");
  16.     action.setParams({
  17.         "currentRecordID": component.get("v.recordId"),
  18.         "currentSObjectName" : component.get("v.sObjectName")
  19.     });
  20.     //Set up the callback
  21.     var self = this;
  22.     action.setCallback(this, function(actionResult) {
  23.         component.set("v.currentRecordDuns", actionResult.getReturnValue());  
  24.         this.getAccounts(component);
  25.         this.getLeads(component);
  26.  
  27.         console.log('v.currentRecordDuns: '+component.get("v.currentRecordDuns"));
  28.         console.log('v.AccountNameForLead: ' +component.get("v.AccountNameForLead"));
  29.         console.log('leads: ' + component.get("v.Leads"));
  30.         console.log('account: ' + component.get("v.Accounts"));        
  31.     });        
  32.     $A.enqueueAction(action);
  33. },
  34. getAccounts: function(component) {  
  35.     if(component.get("v.sObjectName") == 'Lead')
  36.     {
  37.         var action = component.get("c.getCompanyNameByDuns");
  38.         action.setParams({
  39.             "dunsNumber": component.get("v.currentRecordDuns"),
  40.         });
  41.         //Set up the callback
  42.         var self = this;
  43.         action.setCallback(this, function(actionResult) {
  44.             component.set("v.AccountNameForLead", actionResult.getReturnValue());
  45.             component.set("v.AccountIDForLead", '1');
  46.         });        
  47.         $A.enqueueAction(action);  
  48.  
  49.     }
  50.  
  51.  
  52.     else
  53.     {
  54.         var action = component.get("c.getAccounts");
  55.         action.setParams({
  56.             "currentDuns": component.get("v.currentRecordDuns"),
  57.             "freeTextFilter": component.find("freeTextFilter").get("v.value")  
  58.         });
  59.         //Set up the callback
  60.         var self = this;
  61.         action.setCallback(this, function(actionResult) {
  62.             component.set("v.Accounts", actionResult.getReturnValue());            
  63.         });        
  64.         $A.enqueueAction(action);
  65.  
  66.     }
  67.  
  68.  
  69. },
  70. getLeads: function(component) {    
  71.     var action = component.get("c.getLeads");
  72.     action.setParams({
  73.         "currentDuns": component.get("v.currentRecordDuns"),
  74.         "freeTextFilter": component.find("freeTextFilter").get("v.value")  
  75.     });
  76.     //Set up the callback
  77.     var self = this;
  78.     action.setCallback(this, function(actionResult) {
  79.         component.set("v.Leads", actionResult.getReturnValue());            
  80.     });        
  81.     $A.enqueueAction(action);
  82.  
  83.  }, })
  84.      
  85. public class AccConListController {
  86.     @AuraEnabled
  87.     public static List<Account> getAccounts(String currentDuns,String freeTextFilter) {
  88.         String q = 'SELECT Id, Name,DunsNumber, BillingCountry, Type, (select name, Phone, Email FROM Contacts where Name like '%' + freeTextFilter +  '%' or Phone like '%' + freeTextFilter +  '%' or Email like  '%' + freeTextFilter +  '%') FROM Account  where DunsNumber=:currentDuns';
  89.         List<Account> accounts= Database.query(q);
  90.         System.debug(q);
  91.         return accounts;
  92.     }
  93. }
  94.      
  95. getAccountsFromServer: function(component) {  
  96.  /// Rest of the code
  97. }
  98.      
  99. <aura:set attribute="else"><span></span></aura:set>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top