• Chad Coffey
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 2
    Likes Given
  • 7
    Questions
  • 8
    Replies
I have an Apex Class that is deleting a large number of record based on a SOQL query that is entered.  I am having a very hard time getting a TestClass Built.  Any help would be greatly appreciated!

Batch Class:
global class TestBatch implements Database.Batchable<sObject>{
   global final String Query;

   global TestBatch(String q){
             Query=q;
   }

   global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<sObject> scope){
          delete scope;
   }

   global void finish(Database.BatchableContext BC){

   }

}


When I run the following script in the console, the records associated with the object are deleted. 

String query = 'SELECT Id FROM jstcl__PlacementTeamMember__c';

Database.executeBatch(new TestBatch(query), 10000);
I have the below trigger built to notify user(s) when a contact is deleted, however, I am struggling with the test class for this trigger.  Any help would be greatly appreciated. 

trigger EmailAfterDelete on Contact (after delete) {
  Messaging.reserveSingleEmailCapacity(trigger.size);
    List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
    for (Contact acct : Trigger.old) {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setToAddresses(new String[] {'ccoffey@brooksource.com'});
        email.setSubject('Deleted Contact Alert');
        email.setPlainTextBody('This message is to alert you that a Contact has been deleted.');
        emails.add(email);
    }
    Messaging.sendEmail(emails);
}
I am working on a validation on a number field that is apart of a managed package so we cannot change the number of decimals.  I need to the field to always have a whole number entered.  The validation I have below, works for the most part, except when 10,20,30 are entered. The Validation work corrects when 15,25, etc are entered.  Any help? 

AND( 
NOT(REGEX(TEXT( jstcl__Burden__c ), "[0-9]+[.]{1}[0-9]{2}")), 
NOT( jstcl__Burden__c =0))
Hello, 

I am trying to render a custom object as a PDF and I have that working, however I want to replace the Title of the Object with something different, so our users can print the page off as a PDF and take on meetings.  Currently the pages Title is the title of the Object, and that title can be misleading if a Client notices.  Any help would be greatly appreacited!

Here is my Visualforce code I have put in a custom button:

<apex:page standardController="Challenger_Sales_Teaching_Agenda__c" renderAs="pdf">
 <apex:detail Relatedlist="false"  />
</apex:page>
I am not looking for a Process Builder as I want to this update automatically and not wait until the Record is saved for this to be updated.  Here is what I ahve started with.  Any help would be greatly appreciated!

trigger <addaccount> on Opportunity (after insert,after update) {

for (Opportunity op : [select Account.Name from Contact.id])
I am looking for help to run a Join Query to find all out Accounts in our Database without Contacts AND Opportuntiy.  I can run the query indepetly, but I would like to join the queries. 

The Query I am runing to find Accounts without Contacts: Select Id, Name From Account Where Id NOT IN (SELECT AccountId FROM Contacts)
Query to find Accounts without Opportunties: Select Id, Name From Account Where Id NOT IN (SELECT AccountId FROM Opportunity)
So our Compnay uses the "New Notes" feature quite a bit in Lighting for tracking purposes with their Contacts.  What we would really like to do is have 4-5 basic Note Templates on each Contact.  This way evey Contact in our system will have similar Note and we can make eveything a bit more Uniform.  Does anyone know if this is possible? 
I am looking for help to run a Join Query to find all out Accounts in our Database without Contacts AND Opportuntiy.  I can run the query indepetly, but I would like to join the queries. 

The Query I am runing to find Accounts without Contacts: Select Id, Name From Account Where Id NOT IN (SELECT AccountId FROM Contacts)
Query to find Accounts without Opportunties: Select Id, Name From Account Where Id NOT IN (SELECT AccountId FROM Opportunity)
I have an Apex Class that is deleting a large number of record based on a SOQL query that is entered.  I am having a very hard time getting a TestClass Built.  Any help would be greatly appreciated!

Batch Class:
global class TestBatch implements Database.Batchable<sObject>{
   global final String Query;

   global TestBatch(String q){
             Query=q;
   }

   global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<sObject> scope){
          delete scope;
   }

   global void finish(Database.BatchableContext BC){

   }

}


When I run the following script in the console, the records associated with the object are deleted. 

String query = 'SELECT Id FROM jstcl__PlacementTeamMember__c';

Database.executeBatch(new TestBatch(query), 10000);
I have the below trigger built to notify user(s) when a contact is deleted, however, I am struggling with the test class for this trigger.  Any help would be greatly appreciated. 

trigger EmailAfterDelete on Contact (after delete) {
  Messaging.reserveSingleEmailCapacity(trigger.size);
    List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
    for (Contact acct : Trigger.old) {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setToAddresses(new String[] {'ccoffey@brooksource.com'});
        email.setSubject('Deleted Contact Alert');
        email.setPlainTextBody('This message is to alert you that a Contact has been deleted.');
        emails.add(email);
    }
    Messaging.sendEmail(emails);
}
I am working on a validation on a number field that is apart of a managed package so we cannot change the number of decimals.  I need to the field to always have a whole number entered.  The validation I have below, works for the most part, except when 10,20,30 are entered. The Validation work corrects when 15,25, etc are entered.  Any help? 

AND( 
NOT(REGEX(TEXT( jstcl__Burden__c ), "[0-9]+[.]{1}[0-9]{2}")), 
NOT( jstcl__Burden__c =0))
I am not looking for a Process Builder as I want to this update automatically and not wait until the Record is saved for this to be updated.  Here is what I ahve started with.  Any help would be greatly appreciated!

trigger <addaccount> on Opportunity (after insert,after update) {

for (Opportunity op : [select Account.Name from Contact.id])
So our Compnay uses the "New Notes" feature quite a bit in Lighting for tracking purposes with their Contacts.  What we would really like to do is have 4-5 basic Note Templates on each Contact.  This way evey Contact in our system will have similar Note and we can make eveything a bit more Uniform.  Does anyone know if this is possible? 
As we all know ,through Salesforce1 we can reveive notifications like 
   You received an approval request.
   Someone mentioned you.

Using Salesforce1, Can I receive some custom notifications like some object or fields are modified?  Can you please afford some official documents?
I want to push custom notifications to Salesforce1 not using Chatter. I found there is api can push notifications to native apps but not Salesforce1 because I don't know the api name of Salesforce1 for iOS. Can anyone help me on this?