• Venkatesh.ax1803
  • NEWBIE
  • 55 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 9
    Replies

I have no Apex coding experience, can someone help me write a test class for the following Apex Trigger?

 

trigger updateCCLookupField on Lead (before insert, before update) {

List<Lead> leads = new List<Lead>();

for (Lead l : Trigger.new)
{
Try
{
Campaign_Codes__c AssociatedCC = [SELECT Id FROM Campaign_Codes__c WHERE CodeOnCC__c= :l.Campaign_Code__c];
l.CC_Lookup__c = AssociatedCC.Id;
}
Catch(Exception e)
{
l.CC_Lookup__c = 'a0zD00000028X59';
}
}
}

I know I am missing something simple here, but I getting a:

 

Apex script unhandled trigger exception by user/organization: 0055000000118E4/00D50000000784t

Update_NCOA_Address_v01: System.LimitException: Too many DML rows: 10001

 

Error Message.

 

1.  Can someone spot my error?

2.  Is there a way to put into the code or error message which record(s) triggered the error?

 

trigger Update_NCOA_Address_v01 on printsf__Collateral_Send_History__c(after insert, after update) {
    // Update the appropriate SD_Member__c record with NCOA address from PrintSF
    List<SD_Member__c > recordsToUpdate = new List<SD_Member__c >();
    For(printsf__Collateral_Send_History__c CSH: Trigger.new) {
        // Get the SD Member Id from the recipient id field 
        //String strSDId = CSH.printsf__Recipient_ID__c;

// Check to see if it is an SD Member Entry        
If(CSH.printsf__Recipient_ID__c!=null){   
     
        If(CSH.printsf__NCOA_Result__c == 'None') {
            SD_Member__c SD = New SD_Member__c(id = CSH.printsf__Recipient_ID__c,
                NCOA_Address__c = CSH.printsf__Street__c,
                NCOA_City__c = CSH.printsf__city__c,
                NCOA_State__c = CSH.printsf__State__c,
                NCOA_Zip__c = CSH.printsf__Zip_Code__c,
                NCOA_Error_Code__c = CSH.printsf__NCOA_Result__c,
                NCOA_Error_Description__c = CSH.printsf__NCOA_Result_Description__c);
            recordsToUpdate.add(SD);
        }

        If(CSH.printsf__NCOA_Result__c == 'Fowarded') {
            SD_Member__c SD = New SD_Member__c(id = CSH.printsf__Recipient_ID__c,
                NCOA_Address__c = CSH.printsf__Street__c,
                NCOA_City__c = CSH.printsf__city__c,
                NCOA_State__c = CSH.printsf__State__c,
                NCOA_Zip__c = CSH.printsf__Zip_Code__c);
            recordsToUpdate.add(SD);
        }

        If(CSH.printsf__NCOA_Result__c == 'Failed') {
            SD_Member__c SD = New SD_Member__c(id = CSH.printsf__Recipient_ID__c,
                NCOA_Address__c = CSH.printsf__Street__c,
                NCOA_City__c = CSH.printsf__city__c,
                NCOA_State__c = CSH.printsf__State__c,
                NCOA_Zip__c = CSH.printsf__Zip_Code__c,
                Address_Bad__c = True);

            recordsToUpdate.add(SD);
        }

    
  
  update recordsToUpdate;
}

}}

 Thanks for the help.

i am trying to create enterprise.jar form enterprise.wsdl file, but getting follwoing error

C:\Users\vpuppala002\Desktop\Jar files>"C:\Program Files\Java\jdk1.7.0_51\bin\ja
va" -classpath .\force-wsc-29.0.0.jar com.sforce.ws.tools.wsdlc .\enterprise.wsd
l .\enterprise.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/stringtemplate/v4
/STGroupDir
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
        at java.lang.Class.getMethod0(Class.java:2774)
        at java.lang.Class.getMethod(Class.java:1663)
        at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)

Caused by: java.lang.ClassNotFoundException: org.stringtemplate.v4.STGroupDir
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
       
i did not understand why this class errors i am getting ?

When we write trigger on event after insert and after update event to update field on different object, then should we always the DML operator at the last like:

 

insert myList;

update myList;

 

Can some one give an example?

  • August 13, 2013
  • Like
  • 0

I am getting this exception even after I am providing LIMIT of 5000 to the following dynamic SOQL query:

 

strCamMemQuery = 'SELECT Id,Name,LastName,Initials__c,AccountId,Email ';
strQuery=' FROM Contact WHERE Id NOT IN :existingCampaignMembers ';
strQuery+='AND AccountId IN:acts ';

strCamMemQuery += ' LIMIT 5000';

 

List<Contact> cl = Database.query(strCamMemQuery);

 

Please let me know what is the causing the error.

 

I have no Apex coding experience, can someone help me write a test class for the following Apex Trigger?

 

trigger updateCCLookupField on Lead (before insert, before update) {

List<Lead> leads = new List<Lead>();

for (Lead l : Trigger.new)
{
Try
{
Campaign_Codes__c AssociatedCC = [SELECT Id FROM Campaign_Codes__c WHERE CodeOnCC__c= :l.Campaign_Code__c];
l.CC_Lookup__c = AssociatedCC.Id;
}
Catch(Exception e)
{
l.CC_Lookup__c = 'a0zD00000028X59';
}
}
}

Hi,

 

I am new to Salesforce triggers. I want to populate the custom lookup "Contact Name" field on Opportunity screen whenever Lead gets converted.

 

Thanks,

SFBeginner

Please Reply to this requirement urgently with code.

 

One Account present in salesforce (Flipcart application) and  that acclunt email id =abc@gmail.com.

 

If I send email from particular email id (abc@gmail.com) to sales@flipcart.com, automaticllay one record with Email subject should be stored in Notes & Attachment of particular account.

 

Please help me

I know I am missing something simple here, but I getting a:

 

Apex script unhandled trigger exception by user/organization: 0055000000118E4/00D50000000784t

Update_NCOA_Address_v01: System.LimitException: Too many DML rows: 10001

 

Error Message.

 

1.  Can someone spot my error?

2.  Is there a way to put into the code or error message which record(s) triggered the error?

 

trigger Update_NCOA_Address_v01 on printsf__Collateral_Send_History__c(after insert, after update) {
    // Update the appropriate SD_Member__c record with NCOA address from PrintSF
    List<SD_Member__c > recordsToUpdate = new List<SD_Member__c >();
    For(printsf__Collateral_Send_History__c CSH: Trigger.new) {
        // Get the SD Member Id from the recipient id field 
        //String strSDId = CSH.printsf__Recipient_ID__c;

// Check to see if it is an SD Member Entry        
If(CSH.printsf__Recipient_ID__c!=null){   
     
        If(CSH.printsf__NCOA_Result__c == 'None') {
            SD_Member__c SD = New SD_Member__c(id = CSH.printsf__Recipient_ID__c,
                NCOA_Address__c = CSH.printsf__Street__c,
                NCOA_City__c = CSH.printsf__city__c,
                NCOA_State__c = CSH.printsf__State__c,
                NCOA_Zip__c = CSH.printsf__Zip_Code__c,
                NCOA_Error_Code__c = CSH.printsf__NCOA_Result__c,
                NCOA_Error_Description__c = CSH.printsf__NCOA_Result_Description__c);
            recordsToUpdate.add(SD);
        }

        If(CSH.printsf__NCOA_Result__c == 'Fowarded') {
            SD_Member__c SD = New SD_Member__c(id = CSH.printsf__Recipient_ID__c,
                NCOA_Address__c = CSH.printsf__Street__c,
                NCOA_City__c = CSH.printsf__city__c,
                NCOA_State__c = CSH.printsf__State__c,
                NCOA_Zip__c = CSH.printsf__Zip_Code__c);
            recordsToUpdate.add(SD);
        }

        If(CSH.printsf__NCOA_Result__c == 'Failed') {
            SD_Member__c SD = New SD_Member__c(id = CSH.printsf__Recipient_ID__c,
                NCOA_Address__c = CSH.printsf__Street__c,
                NCOA_City__c = CSH.printsf__city__c,
                NCOA_State__c = CSH.printsf__State__c,
                NCOA_Zip__c = CSH.printsf__Zip_Code__c,
                Address_Bad__c = True);

            recordsToUpdate.add(SD);
        }

    
  
  update recordsToUpdate;
}

}}

 Thanks for the help.