• Malik Butler 5
  • NEWBIE
  • 35 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 9
    Replies
I'm trying to add the opportunity and work order object to this apex class and I've tried everything but haven't had any luck. Any ideas?

public with sharing class CaseActivityController {
    
    public List<Task> lstTask {get;set;}
    
    public CaseActivityController(ApexPages.StandardController std) 
    {
        Id AccountId = std.getId(); //Get AccountId
        
        //Query on Task
        Map<Id, Case> mapIdToCase = new Map<Id,Case>([Select Id from Case WHERE AccountId =: AccountId]);
        
        //Query on Case Activity 
        lstTask = new List<Task>([SELECT CallType,Status,Subject,WhatId,ActivityDate,Description FROM Task WHERE WhatId IN: mapIdToCase.keySet() ORDER BY ActivityDate]);
        
    }

}
Hi, 

I have this post created with an user that no longer exists and I want to delete it because it contains some personal data. Is there a way to delete the post?

Link to the post:
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000kFfBIAU

Thank you!
I have created a visualforce page that displays a chatter group. We are using this chatter group mainly to mention records, which require rich text and this visualforce page doesn't seem to have it. 

<apex:page lightningStylesheets="True"   >
  <chatter:feed entityId="0F90v0000008zhtCAA"/>
</apex:page>

This is the code I have. Is there anything I can do to make this rich text or just completely duplicate the chatter group page.
I'm trying to execute an apex class. I keep running this:
String q = 'SELECT Reload,Pre-Trip report,Post-Trip report,ParentRecordType,ID, O, Date.today()';
Database.executeBatch(new ServiceAppointmentCancel(), 200);
But it is not executing what it is supposed to in the code. 
global class ServiceAppointmentCancel implements Database.Batchable<SObject>, Schedulable
{ 
    global Database.QueryLocator start(Database.BatchableContext BC) 
    { 
        String subject = 'Reload,Pre-Trip report,Post-Trip report'; 
        String status = 'O'; 
        Date SchedEndTime = Date.today();
        String ParentRecordType = 'Work Order' ;
        String ID = 'WorkOrder.ID';
        String query = 'SELECT Subject,Status, SchedEndTime, ParentRecordType FROM ServiceAppointment WHERE subject = :subject AND status = :status AND SchedEndTime < :SchedEndTime AND ParentRecordType = :ParentRecordType AND ID = :ID'; 
    return Database.getQueryLocator(query);
    } 

    global void execute(Database.BatchableContext BC, List<WorkOrder> serviceAppointments) 
    { 
        // Loop to iterate over the service appointments 
        for(WorkOrder service : serviceAppointments)
        
        { 
            service.status = 'C';
        } 
        for(WorkOrder work : serviceAppointments)
        {
            work.status = 'C';
        }
        // Preforming the DML operation 
        update serviceAppointments;
    } 

    global void finish(Database.BatchableContext BC) 
    { } 

    global void execute(System.SchedulableContext SC) 
    { 
        Database.executeBatch(new ServiceAppointmentCancel(), 200); 
    } 
}

 
I have an issue in the debug section it's saying that the ParentRecordType is an unexpected token for service appointments. 
global class ServiceAppointmentCancel implements Database.Batchable<SObject>, Schedulable
{ 
    global Database.QueryLocator start(Database.BatchableContext BC) 
    { 
        String subject = 'Reload,Pre-Trip report,Post-Trip report'; 
        String status = 'O'; 
        Date SchedEndTime = Date.today();
        String ParentRecordType = 'Work Order';
        String ID = 'WorkOrder.ID';
        String query = 'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment WHERE subject = :subject AND status = :status AND SchedEndTime < :SchedEndTime' + 'SELECT ParentRecordType, FROM ServiceAppointment WHERE ParentRecordType = :ParentRecordType AND ID = ID'; 
        return Database.getQueryLocator(query); 
    } 

    global void execute(Database.BatchableContext BC, List<WorkOrder> serviceAppointments) 
    { 
        // Loop to iterate over the service appointments 
        for(WorkOrder service : serviceAppointments)
        
        { 
            service.status = 'C';
        } 
        for(WorkOrder work : serviceAppointments)
        {
            work.status = 'C';
        }
        // Preforming the DML operation 
        update serviceAppointments;
    } 

    global void finish(Database.BatchableContext BC) 
    { } 

    global void execute(System.SchedulableContext SC) 
    { 
        Database.executeBatch(new ServiceAppointmentCancel(), 200); 
    } 
}
I have a batch job that is giving me an error when I use the execute anonymous window. Any ideas of what this coud be? 
global class ServiceAppointmentCancel implements Database.Batchable<SObject>, Schedulable{ global Database.QueryLocator start(Database.BatchableContext BC) { String subject = 'Reload'; String status = 'O'; Date scheduledEnd = Date.today(); String query = 'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment ' + ' WHERE subject = : ' + subject + ' AND status = :' + status + ' AND scheduledEnd < ' + scheduledEnd; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<ServiceAppointment> serviceAppointments) { // Loop to iterate over the service appointments for(ServiceAppointment service : serviceAppointments) { service.status = 'C'; } // Preforming the DML operation update serviceAppointments; } global void finish(Database.BatchableContext BC) { } global void execute(System.SchedulableContext SC) { Database.executeBatch(new ServiceAppointmentCancel(), 200); } }

String q = 'SELECT Reload, O, Date.today()'; Database.executeBatch(new ServiceAppointmentCancel(), 200);

User-added image
 
I have a batch job that needs to be finished but I'm not sure how to finish it
global class ReloadCancellation implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'SELECT Subject,Status,SchedEndTime FROM Service Appointment';
        return Database.getQueryLocator(query);
    }

}

. The criteria is "We  would like to cancel any "Reload" service appointments that are Open from the day before.
 
Create batch to query all the service appointments where:
 
  • ServiceAppointment.Subject = “Reload”
  • and ServiceAppointment.Status = “O” (Open)
  • and ServiceAppointment.ScheduledEnd  less than Today
 
Set to ServiceAppointment.Status = “C” (Canceled)
 
We will run batch at 4:00 AM and it will run Under Integration Account." Attached is what I have so far with the code.