• 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]);
        
    }

}
I created an apex class that shows related object activity on an account page. I am not able to get chatter feed though. I also am able to get one object but I'd like to add opportunities and work orders. Any ideas on what I should do?
I'm trying to create a component that shows related activity on the account page. But it's only showing the last object. Any ideas on how to fix this? Also is there a way to add the chatter feed?


public with sharing class CaseActivityController {
    
    public List<Task> lstTask {get;set;}
    
    public CaseActivityController(ApexPages.StandardController std) 
    {
        Id AccountId = std.getId(); //Get AccountId
        
        //Query on Case
        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]);
        
        //Query on Contact
        Map<Id, Contact> mapIdToContact = new Map<Id,Contact>([Select Id from Contact where AccountId =: AccountId]);
        
        //Query on Contact Activity 
        2ndTask = new List<Task>([SELECT CallType,Status,Subject,WhatId,ActivityDate,Description FROM Task WHERE WhatId IN: mapIdToContact.keyset() ORDER BY ActivityDate]);
         
        //Query on Opportunity
        Map<Id, Opportunity> mapIdToOpportunity = new Map<Id,Opportunity>([Select Id from Opportunity where AccountId =: AccountId]);
        
        //Query on Opportunity Activity 
        3rdTask = new List<Task>([SELECT CallType,Status,Subject,WhatId,ActivityDate,Description FROM Task WHERE WhatId IN: mapIdToOpportunity.keyset() ORDER BY ActivityDate]);
    }
}
I am trying to make a lead owner change approval process. I thought I was good with the code but nothing is triggering. Can anyone help?

trigger LeadReassignment on Lead (before update) {
    for (Lead obj: trigger.new){


        List<Lead> ld = [SELECT Id, OwnerID, Reassignment_Status__c FROM Lead WHERE Id IN :Trigger.old];

        List<ProcessInstance> pi = [SELECT SubmittedById,SystemModstamp,TargetObjectId, Status,  (SELECT ID, ProcessNodeId, StepStatus, Comments,TargetObjectId,ActorId,CreatedById,IsDeleted,IsPending, OriginalActorId,ProcessInstanceId,RemindersSent,CreatedDate 
        FROM StepsAndWorkitems ) FROM ProcessInstance pi WHERE pi.TargetObjectId IN :Trigger.old order by createddate DESC limit 1];


        If (ld[0].Reassignment_Status__c == 'Pending' && pi[0].Status == 'Approved') {
            obj.OwnerID = pi[0].SubmittedById;
            obj.Reassignment_Status__c = '';
            system.debug('Reassignment Approved - Owner Changed from '+ld[0].OwnerId+'to ' +pi[0].SubmittedById);
                                                        }

         If (ld[0].Reassignment_Status__c == 'Pending' && pi[0].Status == 'Rejected') {
            obj.Reassignment_Status__c = '';

            system.debug('Reassignment Rejected - Owner not changed');

                                                         }
 
I need to create a regex that hides fields after being entered. Some are text fields some are numbers is there anyone that can help?
I'm trying to create a replica of the activity feed in a lightning component but would show related cases activity. I have zero idea how to do this but I would like it to show all of the fields that are being tracked. Can anyone help?
I have an approval process that I need created. I currently have a validation rule to restrict users from changing lead owners but I can't make that happen via approval process. Any thoughts on how I could get the approval process based off of the criteria
I've been tasked with resolving an issue where we cannot see the related to field in the task list view. The issue is that this is for the mobile salesforce app and I'm not sure how to do this. Any ideas? 
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 created a lookup relationship between leads and campaigns. When I go to add a campaign to the related list in leads the "New" button does not show up. How do I get this button to display?User-added imageUser-added image
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); 
    } 
}

 
Is there a way to add a hyperlink to an asset object?
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 bacth job that needs updated. I have some criteria that needs added. I have half of it but I'm not sure how to finish it. Here's the criteria:
Create batch to query all the service appointments where:
 
  • ServiceAppointment.Subject = “Reload” or “Pre-Trip report” or “Post-Trip report”
  • and ServiceAppointment.Status = “O” (Open)
  • and ServiceAppointment.ScheduledEnd  less than Today
 
Set to ServiceAppointment.Status = “C” (Canceled)
And If ServiceAppointment.ParentRecordType = “Work Order”,
Then Set WorkOrder.Status = “C” (Canceled) where WorkOrder.ID = ServiceAppointment.ParentID
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 query = 'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment WHERE subject = :subject AND status = :status AND SchedEndTime < :SchedEndTime'; 

        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); 
    } 
}

 
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
 
Is there anyway to add a hyperlink to an asset and send field info like the asset ID to the hyperlink?
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.
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.