• Saswat Mohanty
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 4
    Replies
Hello,

Currently in our org there are many batch jobs which run and perform certain activities. Now the requirement is to notify the admin immediately via email when any of the batch jobs is failed . Though I know, there is a mail template which can be implemented in finish method of each batch job, however it is difficult to put in every batch jobs as it is time consuming.

Could you please help in getting a common class which will check what are the batch jobs that finish the run for a particular day(ideally every day) and then for failed jobs it will send immediate email notification?
We have certain accounts in the org which contain "\" in their names. Also, there is a 3rd party mobile application which is being managed in the org for visit record sync,upload and download purposes. However, when you schedule visit from the calendar with such accounts and download them to mobile app and complete, sync the records it gives the error "An Invalid XML character (0*0) found in the element content of the document".

We saw that in online, for such visits the subject line is being created with additional space of characters and if you remove them by pressing backspace for 2 times, then the subject line gets corrected and accordingly the error is removed. However, the same issue did not happen for any accounts containing forward slash /.

Please suggest how to overcome the issue of invalid xml character
Hello,

We have certain accounts in the org which contain "\" in their names. Also, there is a 3rd party mobile application which is being managed in the org for visit record sync,upload and download purposes. However, when you schedule visit from the calendar with such accounts and download them to mobile app and complete, sync the records it gives the error message like "Invalid XML Character found in the element content of the document". Please note in SFDC online the calendar is designed with a visual force page.

We saw that in online, for such visits the subject line is being created with additional space of special characters and if you remove them by pressing backspace for 2 times, then the subject line gets corrected and with this the error message from the app starts to disappear slowly. However, the same issue did not happen for any accounts containing forward slash /
Hi, 

Currently in our org there are many batch jobs running. Once they are completed successfully, we need to send a consolidated email of all batch classes. The problem i am facing is once they are successfully completed, i am getting multiple times emails once they are finished. So, let's say if i have a batch class on Account to update a field and if i update 2 accounts, the batch job runs 2 times and sends email 2 times. I want only one email out of it for a whole day.

Could you help please with this code?

public class batchdataviewcon {

    public List<List<String>> getTotalonprocessrecords() {
        return Totalonprocessrecords;
    }


    public List<List<String>> getTotalfailedrecords() {
        return Totalfailedrecords;
    }


    public List<List<String>> getListofrecords() {
        return listofrecords;
    }

public List<List<String>> listofrecords;
public List<List<String>> Totalfailedrecords;
public List<List<String>> Totalonprocessrecords;
public Set<String> setofsucuss;
public batchdataviewcon()
{
 listofrecords=new List<List<String>>();
 Totalfailedrecords=new List<List<String>>();
 Totalonprocessrecords=new List<List<String>>();
 setofsucuss=new Set<String>();

 for(AsyncApexJob a : [select TotalJobItems, Status, NumberOfErrors, MethodName, JobType, JobItemsProcessed, ExtendedStatus, Id, CreatedDate, CreatedById, CompletedDate, ApexClassId From AsyncApexJob WHERE JobType='BatchApex' order by CreatedDate desc])
 {
  
  system.debug('list------------------------'+a);
  //success list
  List<String> ls=new List<String>();
  
  //failed list
   List<String> failed=new List<String>();
   //processing list
   List<String> onprocess=new List<String>();
  ApexClass aC = [SELECT Id, Name FROM ApexClass WHERE Id =:a.ApexClassId];
  system.debug('batch class name----------------'+aC);
  if(a.NumberOfErrors==0 & a.Status=='Completed') 
  {
   ls.add(aC.Name);
   ls.add(a.status);
   setofsucuss.add(aC.Name);
   setofsucuss.add(String.valueof(a.CreatedDate));
    system.debug('set of records ----------------'+setofsucuss);
   listofrecords.add(ls);
   
  }
  if(a.NumberOfErrors!=0 & a.Status=='Completed')
  {
  failed.add(aC.Name);
  failed.add(a.status);
  failed.add(a.ExtendedStatus);
  Totalfailedrecords.add(failed);
  }
   //ls.clear();
   
  if(a.NumberOfErrors==0 & a.Status=='Processing')
  {
  onprocess.add(aC.Name);
  onprocess.add(a.status);
  Totalonprocessrecords.add(onprocess);
  }
 }
 system.debug('listofrecords----------------'+listofrecords);

//sendmailnofication();

}
 
 //delete till yesterday batch records.
 /*public PageReference methodtodeleteoldjobs()
 
 {
 Integer count = System.purgeOldAsyncJobs(Date.today());
 System.debug('-----------Deleted------------------ ' + count + ' old jobs.');
  return null;
 }*/
 //mail notification
 public void sendmailnofication()
 {
 
   Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
   String[] toAddresses = new String[] {'saibabu.salesforce@gmail.com','saswat-kumar.x.mohanty@gsk.com'};
   mail.setToAddresses(toAddresses);
   mail.setReplyTo('sm00364377@techmahindra.com');
   
   mail.setSenderDisplayName('Salesforce Support');
   mail.setSubject('Status of Batch classes : ');
   mail.setBccSender(false);
   mail.setUseSignature(false);
   mail.setHtmlBody('The below batch clasees are executed sucussfully with the latest time stamp: '+setofsucuss);
   system.debug('----------------------------2---------------');    
   Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
   

}
}
Hi all,

We have 2 batch classes developed on contact and on one custom object. If everytime these 2 objects are updated, the batch class runs showing the progress which we are showing in a visualforce page.

Also, we have designed a mail template in class so that everytime the batch jobs are finished the email will be triggered. However, we want to limit the no. of emails at regular intervals. So, how can we receive a single email at the end of the day for every batch class/job sectionwise?
Hello,

Currently in UAT environment, the batch jobs are not running and it shows the error as Apex job named "BatchQueueRunning" is already scheduled for execution.

The possible scenario is after refresh of UAT sandbox from live, two records were imported to UAT which we are unable to delete.

• one record for object "CronTrigger"
• one record for object "CronJobDetail

Also, even though we want to change the scheduler class name we can not do so as those dirty records are using the schedule apex class.

Could you please help.
Hello,

Currently in our org there are many batch jobs which run and perform certain activities. Now the requirement is to notify the admin immediately via email when any of the batch jobs is failed . Though I know, there is a mail template which can be implemented in finish method of each batch job, however it is difficult to put in every batch jobs as it is time consuming.

Could you please help in getting a common class which will check what are the batch jobs that finish the run for a particular day(ideally every day) and then for failed jobs it will send immediate email notification?
Hello,

We have certain accounts in the org which contain "\" in their names. Also, there is a 3rd party mobile application which is being managed in the org for visit record sync,upload and download purposes. However, when you schedule visit from the calendar with such accounts and download them to mobile app and complete, sync the records it gives the error message like "Invalid XML Character found in the element content of the document". Please note in SFDC online the calendar is designed with a visual force page.

We saw that in online, for such visits the subject line is being created with additional space of special characters and if you remove them by pressing backspace for 2 times, then the subject line gets corrected and with this the error message from the app starts to disappear slowly. However, the same issue did not happen for any accounts containing forward slash /
Hi all,

We have 2 batch classes developed on contact and on one custom object. If everytime these 2 objects are updated, the batch class runs showing the progress which we are showing in a visualforce page.

Also, we have designed a mail template in class so that everytime the batch jobs are finished the email will be triggered. However, we want to limit the no. of emails at regular intervals. So, how can we receive a single email at the end of the day for every batch class/job sectionwise?