• Caroline Poole 9
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I created a schedulable apex class that deletes Marketo Activities in salesforce after a week so our activity volume doesn't get too high.

Is anyone able to help me write a test class for this? Or give me guidance? THANK YOU!!

----

global class DeleteMarketoActivities implements Schedulable{
    global void execute(SchedulableContext SC) {
        List<Task> Obj = [select Id FROM Task WHERE CreatedById = '0050a00000GeV2hAAF' AND CreatedDate != LAST_N_DAYS:7];
            delete Obj;
    }
}
Hi. I found this apex class sample online. It triggered successfully in my sandbox. The trigger finds a string in a custom field and replaces it with a new character. When deploying to my production org, I realized I don't have a test class.

This is the Apex Trigger:
trigger replaceCharactersSB on rC_Connect__Batch_Upload__c (before insert) {
 String str = '&amp;gt;';
    String str2 = '&gt;';
    String replacement = '>';
    for(rC_Connect__Batch_Upload__c des : trigger.new){
        if(des.SB_donation_allocations__c.contains(str)){
            des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str, replacement);
        }
        if(des.SB_donation_allocations__c.contains(str2)){
            des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str2, replacement);
        }
    }
}

Anyone know how to create a test class for this? Thank you for your help!
Hi. I found this apex class sample online. It triggered successfully in my sandbox. The trigger finds a string in a custom field and replaces it with a new character. When deploying to my production org, I realized I don't have a test class.

This is the Apex Trigger:
trigger replaceCharactersSB on rC_Connect__Batch_Upload__c (before insert) {
 String str = '&amp;gt;';
    String str2 = '&gt;';
    String replacement = '>';
    for(rC_Connect__Batch_Upload__c des : trigger.new){
        if(des.SB_donation_allocations__c.contains(str)){
            des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str, replacement);
        }
        if(des.SB_donation_allocations__c.contains(str2)){
            des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str2, replacement);
        }
    }
}

Anyone know how to create a test class for this? Thank you for your help!
I am trying to remove and replace a few strings that are rendering incorrectly for a Rich Text field through an Apex Trigger. Any idea what is incorrect with the following code?
 
trigger removeCharacters on ts2__Job__c (before insert) {
    String str = '\u00A0';
    String str2 = 'Â';
    String replacement = ' ';
    for(ts2__Job__c des : trigger.new){
        if(des.ts2__Job_Advertisement__c.contains(str)){
            des.ts2__Job_Advertisement__c.replace(str, replacement);
        }
        if(des.ts2__Job_Advertisement__c.contains(str2)){
            des.ts2__Job_Advertisement__c.replace(str2, replacement);
        }
    }

}