• krishnag
  • SMARTIE
  • 574 Points
  • Member since 2010

  • Chatter
    Feed
  • 23
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 79
    Questions
  • 259
    Replies

i am wondering if the holiday object can be used to check is the current date is not that of a holiday and how would one go about it?

Does anyone have existing code of dynamically building a dropdown in controller so that on the visualforce page would look like this (it always starts from current month and current year) for the next 24 months:

 

Aug-2010

Sep-2010

Oct -2010

Nov-2010

Dec-2010

Jan-2011

Feb-2011

Mar-2011

...

...

 

with value:

8-2010

9-2010

10-2010

11-2010

12-2010

1-2011

2-2011

3-2011

...

...

 

 

Any help will be greatly appreciated.

I have a trigger that runs on lead update (when a lead is converted to a contact.) . We use demand tools to dedupe leads to leads and then leads to contacts. When we run demand tools its giving me this error

 

UpdateContactOnLeadUpdate: execution of AfterUpdate

 

caused by: System.Exception: Too many SOQL queries: 101

 

Trigger.UpdateContactOnLeadUpdate: line 13, column 25

 

I am pasting the code for my trigger below. Line 13 is where I am getting the recordTypes . Its a single query. I am not sure why its causing this error. 

 

 

trigger UpdateContactOnLeadUpdate on Lead (after Update)
{
  List<String> conIds = new List<String>();
  List<String> leadIds = new List<String>();
  
  Map<String,Lead> leadMap = new map<String,Lead>();
  Map<String,Contact> contactMap = new map<String,Contact>();
  List<Key_Event__c> keyEventsToInsert = new List<Key_Event__c>();
  List<Lead_Key_Event__c> keyEventsToDelete = new List<Lead_Key_Event__c>();
  
  List<Contact> consToUpdate = new List<Contact>();
  
  RecordType[] recType = [Select Id, Name, SobjectType from RecordType 
                                            Where SOBjectType =: 'Key_Event__c'];line13
  
    For(Lead lead : Trigger.new)
    {
        //the lead is just converted
        if(lead.IsConverted == true && Trigger.oldMap.get(lead.Id).IsConverted == false)
        {
          leadIds.add(lead.Id);
          
          leadMap.put(lead.Id,lead);
          
          conIds.Add(lead.ConvertedContactId);
        }
    }
    
    //get the key events for the leads
    List<Lead_Key_Event__c> leadKeyEvents = [Select k.Auto_Demo_Field_1__c,k.Appt_Scheduled_Date__c, k.Auto_demo_Field_2__c,k.Lead_Confirmed_by_RM_NAM__c, 
                      k.Best_time_to_contact_prospects__c,k.Contact_Sales_Comments__c, 
                      k.CreatedById, k.CreatedDate, k.Id, k.IsDeleted, k.Key_Event_Type__c, 
                      k.LastModifiedById, k.LastModifiedDate, k.Lead__c, k.Lead_Created_Date__c, k.Name, 
                      k.Primary_Business_Pain__c, k.Purchase_decision_timeframe__c, 
                      k.Score__c, k.SystemModstamp, k.Trade_Show_Comments__c, k.Webinar_date__c, 
                      k.Webinar_request_date__c, k.Webinar_status__c from Lead_Key_Event__c k where Lead__c IN: leadIds Order By k.CreatedDate ASC];   
    
    
    
    
            //get the contact associated with the lead
    Contact[] contacts = [select Id , Last_KE_Date__c , CPM_Autodemo__c , White_Paper_Download__c,
              Contact_Sales_Request_Form__c,Purchase_Decision_Pending__c ,Recorded_Webinar__c,
              Webcast__c,Webinar__c, AccountId,pi__score__c
                         from Contact Where Id IN :conIds ];
                         
    //set the contact map                     
    For(Contact con : contacts)
    {
      contactMap.put(con.Id,con);
    }
    
    //run through all the lead key events and create corresponding key events for contacts/accounts
    For(Lead_Key_Event__c ke : leadKeyEvents)
    {
      Lead leadObject = leadMap.get(ke.Lead__c);
      Contact contactObject = contactMap.get(leadObject.ConvertedContactId);
    
      Key_Event__c keyEvent = new Key_Event__c();
      keyEvent.Contact__c = contactObject.Id;
      keyEvent.Account__c = contactObject.AccountId;
      keyEvent.Auto_Demo_Field_1__c = ke.Auto_Demo_Field_1__c;
      keyEvent.Auto_demo_Field_2__c = ke.Auto_demo_Field_2__c;
      keyEvent.Best_time_to_contact_prospects__c = ke.Best_time_to_contact_prospects__c;
      keyEvent.Contact_Sales_Comments__c = ke.Contact_Sales_Comments__c;
      keyEvent.Key_Event_Type__c = ke.Key_Event_Type__c;
      keyEvent.Lead_Created_Date__c = ke.Lead_Created_Date__c;
      keyEvent.Name = ke.Name;
      keyEvent.Primary_Business_Pain__c = ke.Primary_Business_Pain__c;
      keyEvent.Purchase_decision_timeframe__c = ke.Purchase_decision_timeframe__c;
      keyEvent.Score__c = ke.Score__c;
      keyEvent.Trade_Show_Comments__c = ke.Trade_Show_Comments__c;
      keyEvent.Webinar_date__c = ke.Webinar_date__c;
      keyEvent.Webinar_request_date__c = ke.Webinar_request_date__c;
      keyEvent.Webinar_status__c = ke.Webinar_status__c;
      keyEvent.Appt_Scheduled_Date__c = ke.Appt_Scheduled_Date__c;
      keyEvent.Lead_Confirmed_by_RM_NAM__c = ke.Lead_Confirmed_by_RM_NAM__c;
      
      String recTypeToSearch;
      
      if(keyEvent.Name == 'Auto Demo')
        recTypeToSearch = 'Key Event Auto Demo';
      if(keyEvent.Name == 'Auto Demo Click Through')
        recTypeToSearch = 'Key Event Auto Demo';
      if(keyEvent.Name == 'White Paper Download')
        recTypeToSearch = 'Key Event White Paper Download';
      if(keyEvent.Name == 'Contact Sales request form')
        recTypeToSearch = 'Contact Sales Request form layout';
      if(keyEvent.Name == 'Purchase Decision pending')
        recTypeToSearch = 'Purchase decision pending';
      if(keyEvent.Name == 'Recorded Webinar')
        recTypeToSearch = 'Recorded webinar';
      if(keyEvent.Name == 'Webcast Attendence')
        recTypeToSearch = 'Webcast attendence';
      if(keyEvent.Name == 'Webinar Request')
        recTypeToSearch = 'Webinar Request';
      if(keyEvent.Name == 'Trade Show')
        recTypeToSearch = 'TradeShow';
      if(keyEvent.Name == 'Webinar Attendence')
        recTypeToSearch = 'Webinar Attendence';
      if(keyEvent.Name == 'Webinar Registration')
        recTypeToSearch = 'Webinar Registration';
      if(keyEvent.Name == 'Appointment Scheduled')
        recTypeToSearch = 'Appointment Scheduled';
      if(keyEvent.Name == 'Appointment Attended')
        recTypeToSearch = 'Appointment Attended';
        
      
      For(RecordType rec : recType)
        {
            if(rec.Name == recTypeToSearch)
                keyEvent.RecordTypeId = rec.Id;
        }
  
      if(contactObject.Last_KE_Date__c == null || (contactObject.Last_KE_Date__c < keyEvent.Lead_Created_Date__c))
        contactObject.Last_KE_Date__c = keyEvent.Lead_Created_Date__c;
      
      if(leadObject.pi__score__c != null)
        {
          if(contactObject.pi__score__c == null)
            contactObject.pi__score__c = leadObject.pi__score__c;
          else
            contactObject.pi__score__c += leadObject.pi__score__c;
        }
      
      List<Contact> refinedContacts = new List<Contact>();
      For(Integer i = 0 ; i < consToUpdate.size() ; i++)
      {
        if(consToUpdate[i].Id != contactObject.id)
        {
          refinedContacts.add(consToUpdate[i]);
        }
      }
      consToUpdate = refinedContacts;
      
      consToUpdate.add(contactObject);
      keyEventsToInsert.add(keyEvent);
      keyEventsToDelete.add(ke);
      
    }
      
    if(keyEventsToInsert.size() > 0)
      insert keyEventsToInsert;  
      
    if(consToUpdate.size() > 0)
      update consToUpdate;
      
    if(keyEventsToDelete.size() > 0)
      delete keyEventsToDelete;
}

 

 

 

 

Hi All,

 

Writing my first test class here and fallen at the first hurdle!

 

To be able to test my class I need to instantiate a load of test objects first of all, so I have written a little class to do that which works fine.

 

The class I want to test is a (will be a) shopping cart that does nothing but instantiate so far.

 

I've started writing the test class to go alongside for my TDD. First I've instantiated all the test objects and written my first test method. However, Force.com IDE complains that objects are not available in my class. So when I try to save  

 

 

@isTest
private class TMDR_ShoppingCartTest {



	testBuildObjects tbo = new testBuildObjects();
	Account a = tbo.createAccount();
	Contact c = tbo.createContact(a.id);
	Opportunity o = tbo.createOpportunity(a.id,c.id);
	OpportunityContactRole ocr = tbo.createOpportunityContactRole(c.id,o.id);
	OpportunityLineItem oli = tbo.createOpportunityLineItem(o.id);
	OpportunityLineItem oli2 = tbo.createOpportunityLineItem(o.id);
	OpportunityLineItem oli3 = tbo.createOpportunityLineItem(o.id);
		
	static testMethod void testInstantiate() {
			
			System.Debug('########Starting Shopping cart tests###########');
			TMDR_ShoppingCart cart = new TMDR_ShoppingCart(o.id);
		
	}

}

 

 

 

 Force.com complains that o.id does not exist!

 

This must be a simple one. Can you help?

 

TIA

 

 

 

 

hi,

 

I want to get some help in writing an SOQL query where the scenario is

 

i want the count of number of contacts where the account its related to have some field abc = true..

 

 

Hi. since january i do triggers and depoloy to production without doing a test class..

Today when im going to deploy one trigger, Production SF get me an error saying "Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required"..

 

I have tested the trigger on sandbox with real case - with insert records..

 

What can i do?

hi,

i need small clarification for the governor limit too many query row limit for a context. I know apex has a governor limit like number of query rows fetched in a context should not be more than 10000. I want to know the limitation is for a query or a sum of all the records for a class.

hi,

 

I am using Google Visualization API for custom Report building on Visualforce pages.IN order to display the data in a graph where i am calculating the yearly data like number of accounts created in this year.

 

I used select count() from Accounts where Lead_Created_Date__c = This_Year; query which fetches the details the count of number of accounts created in this year.

 

I am hitting a governor limit since i have more than 10,000 accounts created this year. I heard that API has no governor limits then why I am getting this limit.I am using this query in controller of the visualforce page.I know the controller is an apex component so i Am getting this limitations.

 

Do u have any alternative suggestions to go ahead with it.

Hi,

 

I am new to Salesforce. Help needed on writing test method. mu current method covers 44% please help to get it 75%.

 

	 	  public with sharing class TallySheetItems {

private ApexPages.StandardController controller {get; set;}

//added an instance varaible for the standard controller
Tally_Sheet__c TS;
String recordId;

public TallySheetItems(ApexPages.StandardController stdController)
{

recordId = stdController.getId();
TS = (Tally_Sheet__c) stdController.getRecord();
this.controller=stdController;  
 
}


                List<TS_NASAAC_Item__c> TallySheetItemList;
                List<TS_NASAAC_Item__c> TallySheetItemList1;
                public double total { get; set; }
                public PageReference reset() {
                     TallySheetItemList= [select ID, MELT__c, BND__c, GR_WT_KGS__c, Tare__c,
                     NET_WT_KGS__c, Melt_Date__c, INGOTS__c, Ref__c, IsDeleted__c from
                     TS_NASAAC_Item__c where Tally_Sheet_Ref__c = :TS.ID and IsDeleted__c = false order by CreatedDate limit 100 ];
                     
                     
                     return null;
                }  
             
                public List<TS_NASAAC_Item__c> getTallySheetItems() {
                     if(TallySheetItemList== null) reset();
                     return TallySheetItemList;
                }
 
                public void setTallySheetItems(List<TS_NASAAC_Item__c> TallySheetItems) {
                      TallySheetItemList = TallySheetItems;
                }
 
                public PageReference saveItem() {
                     total = 0;
                     for(TS_NASAAC_Item__c o: TallySheetItemList)
                     {           
                       if(o.GR_WT_KGS__c!= null)
                       {             
                       total += o.GR_WT_KGS__c;          
                       }
                     }    
                     TS.TOTAL__c = total;     
                     update TS;              
                      upsert TallySheetItemList;
                      reset();
                      return null;
                }
 
                public PageReference add() {
                                TS_NASAAC_Item__c TSI = new TS_NASAAC_Item__c();
                                TSI.Tally_Sheet_Ref__c = TS.ID;
                                TallySheetItemList.add(TSI);
                                return null;
                }
                
                //string RowID;
                //public String getRowID() {return this.RowID;}
                //public List<TS_NASAAC_Item__c> TSIlst { get; set; }              
                //public PageReference DeleteRow()
                //{
                //string RowID = ApexPages.CurrentPage().getParameters().get('RowID');
                
                //TallySheetItemDelList= [select ID, MELT__c, BND__c, GR_WT_KGS__c, Tare__c,
                    // NET_WT_KGS__c, Melt_Date__c, INGOTS__c, Ref__c from
                    // TS_NASAAC_Item__c where ID = :RowID limit 1];
      
               // if ( TallySheetItemDelList.size() > 0 )
                  //    {           
                  //      delete TallySheetItemDelList;   
                 //      }   
                       
                       
                // if for any reason we are missing the reference
                //if (RowID == null)
                //{
                  //return null;      }           
                  // find the account record within the collection      
                  //TS_NASAAC_Item__c tobeDeleted = null;      
                  //for(TS_NASAAC_Item__c a : TSIlst)       
                  //if (a.Id == RowID)
                  //{         
                   //tobeDeleted = a;         
                   // break;       
                    //}           
                     //if account record found delete it     
                     // if (tobeDeleted != null)
                     // {       Delete tobeDeleted;      }                  
                   //reset();           
                //delete TallySheetItemDelList;
               // return null;
                //}
                
                public PageReference ExportExcel()
                {
                 TS.Exported__c = true;
                 update TS;
                 PageReference customPage = Page.vfTallySheetExport;
                 customPage.setRedirect(true);
                 customPage.getParameters().put('id', recordId);
                 return customPage;
                }
                
                public string[] getheaders()
                {
                return new string [] {'Melt#', 'BND#', 'GR WT KGS', 'TARE', 'NET WT KGS', 'Melt Date', 'INGOTS', 'Ref#'} ;
                }
                
                public List<TS_NASAAC_Item__c> getTallySheetItems1() {
                     if(TallySheetItemList== null) reset1();
                     return TallySheetItemList;
                }
                
                 public PageReference reset1() {
                     TallySheetItemList= [select MELT__c, BND__c, GR_WT_KGS__c, Tare__c,
                     NET_WT_KGS__c, Melt_Date__c, INGOTS__c, Ref__c from
                     TS_NASAAC_Item__c where Tally_Sheet_Ref__c = :TS.ID and IsDeleted__c = false order by CreatedDate limit 100 ];
      
                     return null;
                }  
                
                 public PageReference Completed() {
                                TS.Completed__c = true;
                                 update TS;
                                return null;
                }
                
                
     /* Test Case */

static testMethod void myUnitTest() {
 
PageReference PageRef = Page.vfTallySheet;
test.setCurrentPage(PageRef);

Apexpages.Standardcontroller sc = new Apexpages.Standardcontroller(new Tally_Sheet__c());
 List<TS_NASAAC_Item__c> TallySheetItemList;
 List<TS_NASAAC_Item__c> TallySheetItemList1;
 

TallySheetItems controller = new TallySheetItems(sc);
controller.reset();

 TallySheetItemList = null;
controller.getTallySheetItems();

TallySheetItemList= [select ID, MELT__c, BND__c, GR_WT_KGS__c, Tare__c,
NET_WT_KGS__c, Melt_Date__c, INGOTS__c, Ref__c, IsDeleted__c from
TS_NASAAC_Item__c where Tally_Sheet_Ref__c = 'a06T0000008OAyE' and IsDeleted__c = false order by CreatedDate limit 100 ];

controller.add();
controller.ExportExcel();
controller.getheaders();
controller.reset1();
controller.Completed();         
controller.saveItem();

}

/* Test Case ends....*/

 
}

 

 

hey everyone,

 

I am trying to deploy an edited version of a class already scheduled in live salesforce.

 

I am getting the following errors:

errors

 

I have uploaded many small scheduling tasks and triggers into SF without test classes and they've gone through. However, this time i got a Deploy Error. Is there a work around without having to write a ton of test classes?

 

I have done extensive testing in the sandbox for my upload and it has been fine. The edits contained in NDA counter are really small for my the already up and running version in live SF.

 

any help is appreciated. 

Does anyone know the limits of API SOQL calls? I have an aggregate query that, when run inside a VF controller, gives out a Too many query rows (16,125) error. However, the same query ran from SOQLXplorer returns no error and shows me the data.

Ok, here is my issue.  I have 1 class that I am trying to get into production.   Just for simplicity I have only 1 method that returns a list of users.   With this one class I have a the test method, and I get 31% coverage. 

 

1.  Why is it that when I add more methods code coverage goes down?

 

2.  Why can I have my class with the 1 method and a test class completely empty and still have the same coverage as before?

 

3.  Please explain or point me in the right direction about the code coverage.

 

 

Thanks.

Can  any one help me out the step to configure force .com IDE

and also how to deploy the application in production  from sandbox

 

 

 

thanx in advance

hi is it possible to create a field on a custom object which gives the count of Accounts.Like this object should display all the numerical data.

 

field ---> Num Accounts  ---> should give the count of all accounts in the org.

 

I know reports help us to get this info But i need to get this for some other purpose.

Here's the trigger code:

 

trigger ConsecutiveShifts on Shift__c (after insert) {

//Counter will be used to increment the Date for each new shift
Integer Counter = 1;

for(Shift__c a : trigger.new)
{
    Decimal Consec_Shifts = a.Consecutive_Shifts__C;
    While(Consec_Shifts > 1){
        Shift__c b = New Shift__c();
        b.markets__c = a.markets__c;
        b.date__c = a.date__c + Counter;
        b.client__c = a.client__c;
        b.position__c = a.position__c;
        b.shift_start__c = a.shift_start__c;
        b.shift_end__c = a.shift_end__c;
        b.contractor__c = a.contractor__c;
        b.notes__c = a.notes__c;
        b.status__c = a.status__c;
        b.shift_cancelled__c = a.shift_cancelled__c;
        b.last_minute__c = a.last_minute__c;
        b.pic__c = a.pic__c;
        b.Consecutive_Shifts__c = 1;
        Counter++;
        insert(b);
        Consec_Shifts--;
    }
}
}

 

and here is what I thought would be sufficient testing for it...

 

 

 

@isTest
private class TestShift {

    static testMethod void TestShiftInsert() {
        // TO DO: implement unit test
          system.debug('in test method');
      Shift__c l = new Shift__c(Markets__c = 'a0VA00000005DLh', Client__c = '001A0000002KIGB',
      Position__c = 'RPH', Shift_Start__c = '11:00', Shift_End__C = '12:00', Contractor__c = '003A0000001rWdW', Notes__c = 'Testing',
      Consecutive_Shifts__C = 5, Status__C = 'Confirmed', Shift_Cancelled__C = True, Last_Minute__c = True, PIC__c = True);
        try
        {
        insert l;
        }
        catch(DmlException e){
          system.debug(e.getMessage() + 'testing the insertion of a shift.');
        }
    }
}

 

 

Since the trigger is procced off of an inserted shift, I made sure to insert one in my test class. The trigger functions great on my sandbox, I just need to have the testing in place to implement it into Salesforce. It's not showing any coverage for the trigger and I can't figure out why.

 

Thanks for any help!

Hello,

 

I tested the following code in Sandbox and it worked perfectly fine. Granted that the sandbox environment tends to ignore some Failures and Warnings that would otherwise be flagged when deploying to production. Which is exactly what I think is happening now when I try to deploy this code. Any help or suggestions on what i might be missing in this code would be greatly appreciated.

 

Code is as follows:

*********************

public class BUG_RelatedBug
{
    public static testmethod void test1()
    {
        BUG_RelatedBug obj = new BUG_RelatedBug();
        
        SFDC_Bug__c objBug = new SFDC_Bug__c();
        objBug.Problem__c = 'testBug';
        insert objBug;
        objBug.Problem__c= 'test';
                   
        SFDC_Related_Bug__c objRelatedBug = new SFDC_Related_Bug__c();
        objRelatedBug.SFDC_Bug__c = objBug.Id;
        insert objRelatedBug;
        
        obj.allBugs = objBug.Id;
        obj.bugId = System.currentPageReference().getParameters().get('id');
        obj.SaveAll();
        obj.goBack();
    }
    
    public BUG_RelatedBug()
    {
       try
       {
           bugId = System.currentPageReference().getParameters().get('id');
           bugName = [SELECT Name FROM SFDC_Bug__c WHERE SFDC_Bug__c.Id=: bugId LIMIT 1].Name;
       }
       catch(Exception ex)
       {
           // DO NOTHING
       }
    }
    
    public PageReference saveAll()
    {
        list<String> SplitBugArr = allBugs.split(',');
        list<SFDC_Related_Bug__c> listRelatedBug = new list<SFDC_Related_Bug__c>();
        if(SplitBugArr.size() > 0)
        {
            for(Integer i = 0; i < SplitBugArr.size(); i++)
            {
                SFDC_Related_Bug__c ObjRelatedBug = new SFDC_Related_Bug__c();
                ObjRelatedBug.SFDC_Bug__c = bugId;
                ObjRelatedBug.SFDC_Bug_Num__c = SplitBugArr[i];                       
                listRelatedBug.add(ObjRelatedBug);
                
                SFDC_Related_Bug__c ObjRelatedBug2 = new SFDC_Related_Bug__c();
                ObjRelatedBug2.SFDC_Bug__c = SplitBugArr[i];
                ObjRelatedBug2.SFDC_Bug_Num__c = bugId;                       
                listRelatedBug.add(ObjRelatedBug2);
                
                SFDC_Bug__c[] UpdateBug = [SELECT Name FROM SFDC_Bug__c WHERE SFDC_Bug__c.Id=: bugId LIMIT 1];
                if (UpdateBug.size()>0)
                {UpdateBug[0].Status__c = 'Pending - BUG';
                update UpdateBug;
                }
                               
               
            }
            
        }
        if(listRelatedBug.size() > 0)
        {
            insert listRelatedBug;
        }
        return goBack();
    }
    
   public pageReference goBack()
   {
       PageReference pageRef = new PageReference('/'+bugId);
       pageRef.setRedirect(true);
       return pageRef;
   }
    
    
    
    public string bugId
    {
        set
        {
            bugId = value;
        }
        get
        {
            return bugId;
        }
    }
    public string bugName
    {
        set
        {
            bugName = value;
        }
        get
        {
            return bugName;
        }
    }
     public string allBugs
     {
        set
        {
           allBugs = value;
        }
        get
        {
           return allBugs;
        }

     }
     
}

****************

 

I get the following Error Message:

 

"System.DmlException:Insert Failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [SFDC_Bug__c]: [SFDC_Bug__c]"

 

 

Thanks in Advance.