• pmitchell
  • 0 Points
  • Member since 2011

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2

I have a custom object called Deal_Registrations__c that is used in a VF page to submit records that utlimately become leads in SFDC.  


Once the deal reg record is inserted, an after insert trigger drToLead fires and inserts a lead.  The trigger also is an after update and updates the associated lead or opportunity if the record is updated.  

There is another trigger, which writes the lead id to the deal registration and if the lead is updated writes any updates back to the deal registration record.  There is a corresponding trigger for the same actions on the opportunity. 
If I create or update a deal registration record from the Deal Registration tab, everything works fine.  I can update the DR record and write the changes back to the lead, update the lead and write the changes back to the DR record, convert the lead and the new oppty id is written to the DR record, update the Oppty and the DR is updated and update the DR record and have the oppty update.  
If I try to submit the same record from the VF page I created from http://tapp0.salesforce.com/apex/VFPage - I get an error on the trigger that is inserting the lead:  
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, drToLead: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, invalid parameter value: [] Trigger.drToLead: line 35, column 1: []  
Here is the drToLead Trigger:  
trigger drToLead on Deal_Registration__c (after insert, after update) {

    List<Deal_Registration__c> drToLead = new List<Deal_Registration__c>(); 
        for(Deal_Registration__c drs : Trigger.new){
    List<Lead> leadsTocreate = new List<Lead>();
    Lead leadFromDR = new Lead();
    for(Deal_Registration__c dr2Lead : drToLead){
        leadFromDR.FirstName = dr2Lead.First_Name__c;
        leadFromDR.LastName = dr2Lead.Last_Name__c;
        leadFromDR.Company  = dr2Lead.Company__c;
        leadFromDR.City = dr2Lead.City__c;
        leadFromDR.State = dr2Lead.State__c;
        leadFromDR.PostalCode = dr2Lead.Zip__c;
        leadFromDR.Phone = dr2Lead.Phone__c;
        leadFromDR.Email = dr2Lead.Email__c;
        leadFromDR.Decision_Maker__c = dr2Lead.Decision_Maker__c;
        leadFromDR.Purchase_TimeFrame__c = dr2Lead.Time_Frame__c;
        leadFromDR.Budget_Established__c = dr2Lead.Budget__c;
        leadFromDR.Competitor__c = dr2Lead.Competitor__c;
        leadFromDR.DealRegistationID__c = dr2Lead.id;
        leadFromDR.Status = '3 - Sales Ready Lead (SRL)';
        leadFromDR.Type__c = 'Deal Registration';
        leadFromDR.isConverted = false;
        leadFromDR.Deal_Registration_Status__c = 'Submitted';

    system.debug('DR ID is >>>>>>>>'+leadFromDR.dealRegistationID__c);
    insert leadsToCreate;

   Map<String, Lead> lds2Update = new Map<String, Lead>();

        for(Deal_Registration__c du : Trigger.new){
            if(du.Opportunity_id__c == NULL){
                List<Lead> lds = [SELECT FirstName, LastName, Company, City, State, PostalCode, Decision_Maker__c,
                                    Purchase_TimeFrame__c, Budget_Established__c, Competitor__c 
                                    FROM Lead WHERE id = :du.Lead_ID__c];
            for(Lead l2u : lds){    
                l2u.PostalCode = du.Zip__c;
                l2u.Purchase_Timeframe__c = du.Time_Frame__c;
                l2u.State = du.State__c;
                l2u.Phone = du.Phone__c;
                l2u.LastName = du.Last_Name__c;
                l2u.FirstName = du.First_Name__c;
                l2u.Email = du.Email__c;
                l2u.Decision_Maker__c = du.Decision_Maker__c;
                l2u.Competitor__c = du.Competitor__c;
                l2u.Company = du.Company__c;
                l2u.City = du.City__c;

                lds2Update.put(du.id, l2u);
            update lds2Update.values();
    Map<String, Opportunity> os2Update = new Map<String, Opportunity>();

        for(Deal_Registration__c du : Trigger.new){
            if(du.Opportunity_ID__c <> NULL){
                List<Opportunity> opty = [SELECT id, Purchase_TimeFrame__c, Decision_Maker__c, Competitor__c, 
                                        FROM Opportunity WHERE id = :du.Opportunity_ID__c];
            for(Opportunity o2u : opty){    

                o2u.Purchase_TimeFrame__c = du.Time_Frame__c;
                o2u.Decision_Maker__c = du.Decision_Maker__c;
                o2u.Competitor__c = du.Competitor__c; 
                o2u.Budget_Established__c = du.Budget__c;
                os2Update.put(du.id, o2u);
            update os2Update.values();


And here is the VF Controller:  


public with sharing class drController {
  public Contact ptnrRep ;
  public Account partner {get;}
  public List<Lead> ptnrDealRegs = new List<Lead>();
  public List<Opportunity> ptnrOpptys = new List<Opportunity>();
  public Deal_Registration__c dealReg = NULL;
  public String repID;
  public Lead drLead = NULL;
  public String regFirst{get;set;}
  public String regLast{get;set;}
  public String regCompany{get;set;}
  public String regEmail{get;set;}
  public String regPhone{get;set;}
  public String regState{get;set;}
  public String regZip{get;set;}
  public String regBudget{get;set;}
  public String regCompetitor{get;set;}
  public String regCity{get;set;}
  public String timeOption{get;set;}
  public String decMaker{get;set;}
  Public drController (){
      ptnrRep = [SELECT id, FirstName, LastName, Email, Accountid, Account.Type FROM Contact 
              WHERE email =:ApexPages.currentPage().getParameters().get('id') limit 1];
      repID = ptnrRep.id;
  public List<Lead> getDealRegs() {
    ptnrDealRegs = [SELECT id, FirstName, LastName, Phone, Email, Street, City, State, 

PostalCode, Country,Company,
                        Registered_VAR_Rep__c, Registered_VAR_Rep__r.Id, Status, 

                        Purchase_Timeframe__c, Days_Until_Expiration__c, LastModifiedDate, 

Type__c, Registered_VAR_Rep__r.email,
                    FROM Lead 
                    WHERE Registered_VAR_Rep__r.email = :ptnrRep.email AND isConverted=false 

    return ptnrDealRegs;
  public List<Opportunity> getDealRegOpptys(){
    ptnrOpptys = [SELECT id, Name, AccountId, Account.Name, Registered_VAR_Rep__c, 

                    stageName, Deal_Registration_Number__c, Purchase_Timeframe__c, 

                    LastModifiedDate, Lead_Type__c, Registered_VAR_Rep__r.email, 

                    FROM Opportunity
                    WHERE Registered_VAR_Rep__r.email = :ptnrRep.email AND isClosed=false];
    return ptnrOpptys; 

 public pageReference saveDealReg(){ 
    Deal_Registration__c dealReg = new Deal_Registration__c();
    dealReg.First_Name__c= regFirst;
    dealReg.Last_Name__c = regLast;
    dealReg.Company__c = regCompany;
    dealReg.Phone__c = regPhone;
    dealReg.Email__c = regEmail;
    dealReg.City__c = regCity;
    dealReg.State__c = regState;
    dealReg.Zip__c = regZip;
    dealReg.Time_Frame__c = timeOption;
    dealReg.Budget__c = regBudget;
    dealReg.Decision_Maker__c = decMaker;

    insert dealReg;

    pageReference thankYou = new PageReference('/apex/thankYou');
    return thankYou;



I'm hoping someone has an id as to why this is failing. 







I have a requirement here where i need to access the salesforce reports data and put them in field of visualforce page.


Like i am generating a metrics data table where it displays number of accounts created this year,number of contacts created this year and so on. The thing here is i can use the queries but the problem comes up with governor limits query row limitation 10000 records. controller is limited to fetch only 10000 records in the whole context.


So i want to get the already fetched data in the reports and just display them in the table as fields.


Any ideas on this Its real urgent please help me.