• Nisha Warrier
  • NEWBIE
  • 35 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 11
    Replies
Hi,
As I understand, a transaction boundary can be a trigger, a method , anonymous block etc.If I have more than one DML opns in same method, 2 insert operations and if one of them throws an exception, the entire DML operations in that method (boundary) should be rolled back .I was trying this out with 2 simple insert operations.
Account and Lead.Following is the code.It is jsut a sample one and this is not a realistic situation.
public class TransactionCheck {

    public static void insAndUpd(){
        for(integer i=1;i<=3;i++){
           
            try{
              
                Account acn=new Account(Name='ABC Account '+i);
                insert acn;
                System.debug(i+'th Account inserted');
                Lead newLead=new Lead();
                insert newLead;
            }
            catch(DMLException de){
                System.debug('Caught you!!  '+de);
            }
        }
    }
}

Here, each time I call the method from anonymous block, if there is no exception, it should insert accounts as ABC Account 1, ABC Account 2, ABC Account  3 .I purposely created the lead without any data  so that it can throw an exception (Missing field)...
So the ouput what I am expecting is the first debug statement should work saying 1th Account inserted (all the time ).But due to exception,the transaction should be rolled back and no accounts should be inserted rt?
But they are getting inserted everytime .Attaching the log and my page.Plz correct me if I am wrong...User-added imageUser-added image
Hi,
As a newbie, I was trying creating a custom Exception class using developer console.I tried  new>Apexclass.Gave the name MyException.
But it couldn't create the class as it says the class should extend Exception.But I can't write the code without creating the class first in developer console.I know that we do it directly in Setup>Develop>Apex ClassesUser-added image .But is there any reason why this is happening?
Hi ,
I am a certified Salesforce administrator,currently pursuing Salesforce developer certification.
 I would like to volunteer my time to help a non-profit with any Salesforce.com admin/developer tasks to gain more experience in the field.
I was working with an MNC with 7 years development experience in Java.
I am located in Westborough, MA region, but naturally, can work remotely with any English-language org.
If you have any opportunities for me, please feel free to email me on nisha.m.warrier@gmail.com

Thanks,
Nisha
I have a timebased workflow with field update action. Based on field update a trigger will clone the opportunity with new contract dates. Its like renewal of opportunity based on tenure of months.

But the field update action is failing in few occasions. I had enabled "Re-evaluate rule..." option too. But still the action fails. Can anyone please suggest any option to identify the root cause for this?
We want to update roles, and I want to get a list of where roles are used - formulas, workflows, triggers, etc. I have searched with no luck. Thanks
  • October 20, 2016
  • Like
  • 0
Hi All,

The below lines in my Apex Class are not getting covered :
 
global class TestIncidentsEmailProcess implements Schedulable{

   global void execute(SchedulableContext SC){
    try
        {      
         emailProcessing();
        }
         catch(Exception ex)
        {
            System.debug('Exception in method email process: '+ex.getStackTraceString()+':'+ex.getMessage());
        }    
   }   
   public static void emailProcessing(){
   try{
    Set<String> incidentID = new Set<String>();
    List<IncidentsEmail__c> emailRecordsToUpdate = new List<IncidentsEmail__c>();
    Date todaysDate = Date.today();
    List<IncidentsEmail__c> incidentsCreatedOrUpdatedList = [select id,Name,IncidentCreatedDate__c,EmailStatus__c from IncidentsEmail__c where IncidentCreatedDate__c =: todaysDate and EmailStatus__c!='Sent'];
    for(IncidentsEmail__c incidentsEmail :incidentsCreatedOrUpdatedList){

        incidentID.add(incidentsEmail.Name);     
    }
    List<Company_Incidents__c> incList = [select id, Name,company__r.name,company__r.Test_Manager__r.email, Test_Manager_Link_f__c,title__c,Incident__c,Incident_Id__c,Impact__c,Email_Trigger__c,Incident_Formula__c,Open_Date__c from Company_Incidents__c where Id in:incidentID and Email_Trigger__c!='Updated' order by company__r.Test_Manager__r.email,company__r.name,Open_Date__c];
       Map<String, List<Company_Incidents__c>> result = new Map<String, List<Company_Incidents__c>>();
    for (Company_Incidents__c p : incList) {
      String email = p.company__r.Supplier_Manager__r.email;
      if(null != email){
          List<Company_Incidents__c> list1 = result.get(email);
          if (list1 == null) {
              list1 = new List<Company_Incidents__c>();
              result.put(email, list1);
          }
          list1.add(p);
      }
    }         
         for(String emailKey : result.keySet()){
           List<Company_Incidents__c> childList = result.get(emailKey);
          if(childList != NULL && childList.size() > 0){
            List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        
            String Content = AutoNotification.IntimateSMO(childList);
            mail.setHtmlBody(Content);
            mail.setPlainTextBody(Content);
            mail.setSaveAsActivity(false);
            mail.setSubject('SupplierForce Incident Notification');
            for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress]) {
                if(owa.DisplayName.contains('ERM Salesforce Compliance')){
                    mail.setOrgWideEmailAddressId(owa.id); 
                }
            }            
            List<String> toAddress = new List<String>();
             toAddress.add(emailKey);
            mail.setToAddresses(toAddress);
            mails.add(mail);
            Messaging.SendEmailResult[] resultMail =    Messaging.sendEmail(mails, false);
           }
       }        
       List<IncidentsEmail__c> incidentsCreatedOrUpdatedList1 = [select id,Name,IncidentCreatedDate__c,EmailStatus__c from IncidentsEmail__c where IncidentCreatedDate__c =: todaysDate and EmailStatus__c!='Sent'];
       for(IncidentsEmail__c incidentsEmail :incidentsCreatedOrUpdatedList1){
        incidentsEmail.EmailStatus__c = 'Sent';
        emailRecordsToUpdate.add(incidentsEmail);
       }
       System.debug('emailRecordsToUpdate::'+emailRecordsToUpdate);
       update emailRecordsToUpdate;
    }catch(Exception e){
        String recipientAddress = 'suneetha.konda@fmr.com';
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String textbody = 'There has been an error while processing the service manager job from SMIncidents class';
        String textSubject = 'Job error';
        String[] toAddresses = new String[] {recipientAddress};
        mail.setOrgWideEmailAddressId('xxxxxxxxxxxxxxx');
        mail.setToAddresses(toAddresses);
        mail.setSubject(textSubject);        
        mail.setPlainTextBody(textbody);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
    }
   
    }
 }
The lines in bold are not getting covered.Have achieved 39% and need to make it 75%.

Thanks for any help in Advance!
 
Hi,
As I understand, a transaction boundary can be a trigger, a method , anonymous block etc.If I have more than one DML opns in same method, 2 insert operations and if one of them throws an exception, the entire DML operations in that method (boundary) should be rolled back .I was trying this out with 2 simple insert operations.
Account and Lead.Following is the code.It is jsut a sample one and this is not a realistic situation.
public class TransactionCheck {

    public static void insAndUpd(){
        for(integer i=1;i<=3;i++){
           
            try{
              
                Account acn=new Account(Name='ABC Account '+i);
                insert acn;
                System.debug(i+'th Account inserted');
                Lead newLead=new Lead();
                insert newLead;
            }
            catch(DMLException de){
                System.debug('Caught you!!  '+de);
            }
        }
    }
}

Here, each time I call the method from anonymous block, if there is no exception, it should insert accounts as ABC Account 1, ABC Account 2, ABC Account  3 .I purposely created the lead without any data  so that it can throw an exception (Missing field)...
So the ouput what I am expecting is the first debug statement should work saying 1th Account inserted (all the time ).But due to exception,the transaction should be rolled back and no accounts should be inserted rt?
But they are getting inserted everytime .Attaching the log and my page.Plz correct me if I am wrong...User-added imageUser-added image
Hi,
As a newbie, I was trying creating a custom Exception class using developer console.I tried  new>Apexclass.Gave the name MyException.
But it couldn't create the class as it says the class should extend Exception.But I can't write the code without creating the class first in developer console.I know that we do it directly in Setup>Develop>Apex ClassesUser-added image .But is there any reason why this is happening?
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: RRUSHYEG

I have tried with 2-3 dev orgs and still having same error.
I having troube getting past this module. Could someone share their walkthrough with me?  Thanks