• ase aea
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
We are working with a company named G2 and we want to integrate our Salesforce with them. In order to do so they are asking for our Salesforce Webhook Code. Where do I find that?
Hi Team,


While working on the "Trailhead data Manager" and refreshing the data it is throwing this error.

"An error occurred in your last data refresh.

Delete failed. First exception on row 0 with id 0015g0000063XmuAAE; first error: DELETE_FAILED, Your attempt to delete Sample Account for Entitlements could not be completed because it is associated with the following entitlements.: Sample Entitlement ...   "


Can anyone help me with this?..

 
Hi,

I'm modifying an existing trigger that was created to work in a similar fashion on a different object. The Apex Class and Trigger work fine, but in the Test Class, I get  Compile Error: Variable does not exist: Information_Date__c at line 49 column 25. Can anyone help to figure out what's going on? The line in question is: Information_Date__c = date.newInstance(2017, 1, 1),

@isTest
public class testProcessHealthInsurance {
    
    public static void createClientAndHealthInsurance(integer numOfClients, integer numOfHealthInsurance){
        
        list<account> aList = new list<account>();
        
        for(integer i = 1; i <= numOfClients; i++){
            account newA = new account(
                firstname = 'Test',
                lastname = 'Client',
                social_security_number__c = '000-00-0000',
                personBirthdate = date.newInstance(1980, 1, 1),
                gender__c = 'Female',
                ethnicity__c = 'Client refused',
                language__c = 'English',
                hiv_status__c = 'AIDS',
                secondary_disability__c = 'No Secondary Disability'
            );
            aList.add(newA);
        }
    
      insert aList;
        
        list<Health_Insurance_Coverage__c> HealthInsuranceList = new list<Health_Insurance_Coverage__c>();
        
        for(account a : aList){
            for(integer i = 1; i <= numOfHealthInsurance; i++){
                
                if(i<=12){
                    Health_Insurance_Coverage__c d = new Health_Insurance_Coverage__c(
                        Information_Date__c = date.newInstance(2017, i, 1),
                        Covered_by_Health_Insurance__c = 'No',
                        ADAP__c = 'No',
                        Medi_Cal__c = 'No',
                        Medicare__c = 'No',
                        State_Children_s_Health_Insurance__c = 'No',
                        State_Health_Insurance_for_Adults__c = 'No',
                        Veteran_s_Administration_Medical_Service__c = 'No',
                        Employer_Provided_Health_Insurance__c = 'No',
                        Private_Pay_Health_Insurance__c = 'No',
                        Ryan_White__c = 'No',
                        client__c = a.id
                    );                    
                  HealthInsuranceList.add(d);
                    
                } else {
                    Health_Insurance_Coverage__c d = Health_Insurance_Coverage__c(
                        Information_Date__c = date.newInstance(2017, 1, 1),
                        Covered_by_Health_Insurance__c = 'No',
                        ADAP__c = 'No',
                        Medi_Cal__c = 'No',
                        Medicare__c = 'No',
                        State_Children_s_Health_Insurance__c = 'No',
                        State_Health_Insurance_for_Adults__c = 'No',
                        Veteran_s_Administration_Medical_Service__c = 'No',
                        Employer_Provided_Health_Insurance__c = 'No',
                        Private_Pay_Health_Insurance__c = 'No',
                        Ryan_White__c = 'No',
                        client__c = a.id
                    );                
                    HealthInsuranceList.add(d);
                }
            }
        }
        
        insert HealthInsuranceList;
        
        list<Health_Insurance_Coverage__c> dCheck = [select id, client__c, status__c, information_date__c from Health_Insurance_Coverage__c];
        system.debug(dCheck);
        
  }
    
    public static testMethod void insertNewHealthInsurance(){
        
        createClientAndHealthInsurance(1,2);
        
        account a = [select id from account limit 1];
        
        Health_Insurance_Coverage__c d = new Health_Insurance_Coverage__c(
          information_date__c = date.newInstance(2017, 02, 15),
          Covered_by_Health_Insurance__c = 'No',
          ADAP__c = 'No',
          Medi_Cal__c = 'No',
          Medicare__c = 'No',
          State_Children_s_Health_Insurance__c = 'No',
          State_Health_Insurance_for_Adults__c = 'No',
          Veteran_s_Administration_Medical_Service__c = 'No',
          Employer_Provided_Health_Insurance__c = 'No',
          Private_Pay_Health_Insurance__c = 'No',
          Ryan_White__c = 'No',
          client__c = a.id
        );
        
        test.startTest();
        
        insert d;
        
        test.stopTest();
        
        Health_Insurance_Coverage__c dUpdated = [select id, status__c from Health_Insurance_Coverage__c where information_date__c = 2017-02-15];
        
        system.assertEquals('Current',dUpdated.status__c);
        
    }
    
    public static testMethod void insertMultipleHealthInsurance(){
        
        test.startTest();
        
        createClientAndHealthInsurance(1,2);
        
        test.stopTest();
        
        account a = [select id, (select id, status__c, information_date__c from Health_Insurance_and_Medical_Coverage__r order by information_date__c desc, createddate desc) from account limit 1];
        
        for(Health_Insurance_Coverage__c d : a.Health_Insurance_and_Medical_Coverage__r){
            
            if(d.id == a.Health_Insurance_and_Medical_Coverage__r[0].id){
                system.assertEquals('Current',d.status__c);
            } else {
                system.assertEquals('Past',d.status__c);
            }
            
        }
        
    }
    
    public static testMethod void deleteHealthInsurance(){
        
        createClientAndHealthInsurance(1,2);
        
        account a = [select id, (select id, status__c, information_date__c from Health_Insurance_and_Medical_Coverage__r order by information_date__c desc, createddate desc) from account limit 1];
        
        list<Health_Insurance_Coverage__c> dListToDelete = new list<Health_Insurance_Coverage__c>();
        
        Health_Insurance_Coverage__c dToDelete = [select id from Health_Insurance_Coverage__c where status__c = 'current' limit 1];
        
        test.startTest();
        
        delete dToDelete;
        
        for(account aUpdated : [select id, (select id, status__c, information_date__c from Health_Insurance_and_Medical_Coverage__r order by information_date__c desc, createddate desc) from account where id = :a.id]){
            system.assertEquals(1,aUpdated.Health_Insurance_and_Medical_Coverage__r.size());
            for(Health_Insurance_Coverage__c d : aUpdated.Health_Insurance_and_Medical_Coverage__r){
                system.assertEquals('Current',d.status__c);
            }
        }
        
        Health_Insurance_Coverage__c dToUndelete = [select id from Health_Insurance_Coverage__c where isdeleted = true limit 1 ALL ROWS];
        
        undelete dToUndelete;
        
        for(account aUpdated : [select id, (select id, status__c, information_date__c from Health_Insurance_and_Medical_Coverage__r order by information_date__c desc, createddate desc) from account where id = :a.id]){
            system.assertEquals(2,aUpdated.Health_Insurance_and_Medical_Coverage__r.size());
            for(Health_Insurance_Coverage__c d : aUpdated.Health_Insurance_and_Medical_Coverage__r){
                if(d.id == aUpdated.Health_Insurance_and_Medical_Coverage__r[0].id){
                  system.assertEquals('Current',d.status__c);
                } else {
                    system.assertEquals('Past',d.status__c);
                }
            }
        }
        
        test.stopTest();
        
    }
    
    public static testMethod void updateHealthInsuranceDate(){
        
        createClientAndHealthInsurance(1,2);
        
        account a = [select id, (select id, status__c, information_date__c from Health_Insurance_and_Medical_Coverage__r order by information_date__c desc, createddate desc) from account limit 1];
        
        list<Health_Insurance_Coverage__c> dList = new list<Health_Insurance_Coverage__c>();
        
        for(Health_Insurance_Coverage__c d : a.Health_Insurance_and_Medical_Coverage__r){
            if(d.id == a.Health_Insurance_and_Medical_Coverage__r[0].id){
                d.information_date__c = date.newInstance(2016,12,1);
                dList.add(d);
            }
        }
        
        test.startTest();
        
        checkRecursive.reset();
        update dList;
        
        test.stopTest();
        
        account aUpdated = [select id, (select id, status__c, information_date__c from Health_Insurance_and_Medical_Coverage__r order by information_date__c desc, createddate desc) from account limit 1];
        
        list<Health_Insurance_Coverage__c> dListUpdated = new list<Health_Insurance_Coverage__c>();
        
        for(Health_Insurance_Coverage__c d : aUpdated.Health_Insurance_and_Medical_Coverage__r){
            
            if(d.id == aUpdated.Health_Insurance_and_Medical_Coverage__r[0].id){
                system.assertEquals('Current',d.Status__c);
                system.assertEquals(date.newInstance(2017,1,1),d.information_date__c);
            } else {
                system.assertEquals('Past',d.Status__c);
            }
        }
        
    }
    
    public static testMethod void testBulkHealthInsurance(){
        
        createClientAndHealthInsurance(200,10);
        
        list<Health_Insurance_Coverage__c> dListToModify = new list<Health_Insurance_Coverage__c>();
        
        for(Health_Insurance_Coverage__c d : [select id, information_date__c, status__c from Health_Insurance_Coverage__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,10,1),d.information_date__c);
            Health_Insurance_Coverage__c dToUpdate = new Health_Insurance_Coverage__c(
                id = d.id,
              information_date__c = date.newInstance(2017,8,15)
            );
            dListToModify.add(dToUpdate);
        }
        
        checkRecursive.reset();
        update dListToModify;
        
        list<Health_Insurance_Coverage__c> dListToDelete = new list<Health_Insurance_Coverage__c>();
        
        for(Health_Insurance_Coverage__c d : [select id, information_date__c, status__c from Health_Insurance_Coverage__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,9,1),d.information_date__c);
            dListToDelete.add(d);
        }
        
        delete dListToDelete;
        
        for(Health_Insurance_Coverage__c d : [select id, information_date__c, status__c from Health_Insurance_Coverage__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,8,15),d.information_date__c);
        }
        
    }

}
I have had multiple issues creating a dynamic search bar(searching more than one field) that will allow me to search a table over 1000 records. I'm beginning to wonder if it is even possible or no matter what is Salesforce going to give me that error. This is what I have right now in my controller:

public with sharing class modemSearchController {

  private String soql {get;set;}
  public List<Modem__c> modemz {get;set;}
  public Integer noOfRecords{get; set;}
  public Integer size{get; set;}

  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }

  // the current field to sort by. defaults to name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 1500'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public modemSearchController() {
    soql = 'select Name, ModemIPEXT__c, ModemICCID__c, ModemCarrier__c, ModemActive__c from Modem__c';
    runQuery();
  }
 
    public PageReference create()
    {
   
      return Page.modemCreate;
    }

  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }

  // runs the actual query
  public void runQuery() {

    try {
      modemz = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 1000');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'I cant seem to find that record!'));
    }

  }

  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {

    String name = Apexpages.currentPage().getParameters().get('name');
    String IP = Apexpages.currentPage().getParameters().get('IP');
    String ICCID = Apexpages.currentPage().getParameters().get('ICCID');
    String carrier = Apexpages.currentPage().getParameters().get('carrier');

    soql = 'select Name, ModemIPEXT__c, ModemICCID__c, ModemCarrier__c, ModemActive__c from Modem__c';
    if (!name.equals(''))
      soql += ' and Name LIKE \''+String.escapeSingleQuotes(name)+'%';
    if (!IP.equals(''))
      soql += ' and ModemIPEXT__c LIKE \''+String.escapeSingleQuotes(IP)+'%';
    if (!ICCID.equals(''))
      soql += ' and ModemICCID__c LIKE  \''+String.escapeSingleQuotes(ICCID)+'%'; 
    if (!carrier.equals(''))
      soql += ' and ModemCarrier__c includes \"(+carrier+)';

    // run the query again
    runQuery();

    return null;
  }

  // use apex describe to build the picklist values
  public List<String> carriers {
    get {
      if (carriers == null) {

        carriers = new List<String>();
        Schema.DescribeFieldResult field = Modem__c.ModemCarrier__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          carriers.add(f.getLabel());

      }
      return carriers;         
    }
    set;
  }
 
           
    public ApexPages.StandardSetController setCon {
        get{
            if(setCon == null){
                size = 15;
                string queryString = 'SELECT Name, ModemManufacturer__c, ModemModel__c, ModemICCID__c, ModemIPEXT__c, ModemCarrier__c, ModemActive__c FROM Modem__c ORDER BY Name';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();
            }
            return setCon;
        }
        set;
    }
 
      public List<Modem__c> getModem()
    {
        List<Modem__c> modemList = new List<Modem__c>();
        for(Modem__c m : (List<Modem__c>)setCon.getRecords())
            modemList.add(m);
            return modemList; 
      
    }
 
      public PageReference refresh() {
        setCon = null;
        getModem();
        setCon.setPageNumber(1);
        return null;
    }
 
  public Boolean hasNext
    {
        get {
            return setCon.getHasNext();
        }
        set;
    }
    public Boolean hasPrevious
    {
        get {
            return setCon.getHasPrevious();
        }
        set;
    }
 
    public Integer pageNumber
    {
        get {
            return setCon.getPageNumber();
        }
        set;
    }
   
 
    public void first()
    {
        setCon.first();
    }
 
    public void last()
    {
        setCon.last();
    }
 
    public void previous()
    {
        setCon.previous();
    }
 
    public void next()
    {
        setCon.next();
    }

}



My biggest issue here is 1. It will not allow me to display over 1000 records and I couldnt find a work around. and 2. It will not perform the search within the data, it comes up with an error and displays that it is finding Querying correct at the bottom but it will not actually display the records related to what is being searched.