function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Leo DarkstarLeo Darkstar 

Why is this method not executing ?

I am using Process Builder to call this class. Everything is running correctly in it, except it is not running the last method which I have running at the end. At first I thought it had something to do with the @Future command, but it still didn't execute even after I commented that out. Do you have any idea why that last method at the end of the class is not running ? Does it possibly have anything to do with the fact that I'm calling it with Process Builder ? Do I need an @InvocableMethod in front of that method as well ? 

 

public class UpdateContactPCRController_SELECTED {


    @InvocableMethod
    public static List<String> updateContact(List<String> recordId){ 
        
        //Variable to hold the contact Id
        String contactId = '';
        
        //List ot update contact
        List<Contact> contactToBeupdate = new List<Contact>();
        

        if(recordId.size()> 0){  
            
            //Get Program Contact Role
            //List<Program_Contact_Role__c> programContacList = [SELECT Id,Contact__c,Program_Name__c FROM Program_Contact_Role__c WHERE Id =:recordId AND Contact__c != null];
            //SELECTED
            List<Program_Contact_Role__c> programContacList = [SELECT Id,Contact__c,Program_Name__c FROM Program_Contact_Role__c WHERE Id =:recordId[0] AND Contact__c != null];
            System.debug(recordId[0]);
    
            //if(programContacList.size() > 0)
                contactId = programContacList[0].Contact__c;
                
            
            if(String.isNotBlank(contactId)){
                
                contactToBeupdate = [Select Id,Pardot_Action_Trigger__c,PCR_Register_Button_Link__c,PCR_URL_for_UI__c FROM Contact Where Id =: contactId Limit 1];
                
                contactToBeupdate[0].Pardot_Action_Trigger__c = 'Send Welcome Email';                contactToBeupdate[0].Program_Contact_Role_Id__c = recordId[0];
            }
            
  

            List<Program_Communication_Recipients__c> programCommunicationRecs = [Select Id,Name,Program_Communication__r.Welcome_Message__c,
                                                                                         Program_Communication__r.Program__r.Buyer__r.Name,Receipient__c,
                                                                                         Program_Communication__r.Program__r.Buyer__r.Account_Name_for_Communications__c,
                                                                                         Program_Communication__r.Logo_Public_Url__c ,Welcome_Page_with_IDs__c, 
                                                                                         Program_Communication__r.URL_for_UI__c ,Program_Communication__r.Learn_More_link__c,
                                                                                         Program_Communication__r.Reply_to_Email__c,Program_Communication__r.From_Email__c                
                                                                                         From Program_Communication_Recipients__c Where 
                                                                                         Program_Communication__r.Program__c =: programContacList[0].Program_Name__c AND 
                                                                                         Receipient__c =: programContacList[0].Id];
                                                   
            
            if(programCommunicationRecs.size() > 0){
                
                if(String.isNotBlank(programCommunicationRecs[0].Welcome_Page_with_IDs__c))
                    contactToBeupdate[0].PCR_Register_Button_Link__c = programCommunicationRecs[0].Welcome_Page_with_IDs__c;
                
                
                
                if(String.isNotBlank(programCommunicationRecs[0].Program_Communication__r.Learn_More_link__c))
                            contactToBeupdate[0].PCR_Learn_More_Link__c = programCommunicationRecs[0].Program_Communication__r.Learn_More_link__c;
                        
                if(String.isNotBlank(programCommunicationRecs[0].Program_Communication__r.URL_for_UI__c))
                    contactToBeupdate[0].PCR_URL_for_UI__c = programCommunicationRecs[0].Program_Communication__r.URL_for_UI__c;
                    

               
               if(String.isNotBlank(programCommunicationRecs[0].Program_Communication__r.Program__r.Buyer__r.Account_Name_for_Communications__c))
                    contactToBeupdate[0].PCR_Buyer_Name__c = programCommunicationRecs[0].Program_Communication__r.Program__r.Buyer__r.Account_Name_for_Communications__c;
               if(String.isBlank(programCommunicationRecs[0].Program_Communication__r.Program__r.Buyer__r.Account_Name_for_Communications__c))
                    contactToBeupdate[0].PCR_Buyer_Name__c = programCommunicationRecs[0].Program_Communication__r.Program__r.Buyer__r.Name;
               //END CHANGE
                
                if(String.isNotBlank(programCommunicationRecs[0].Program_Communication__r.Welcome_Message__c) && String.valueOf(programCommunicationRecs[0].Program_Communication__r.Welcome_Message__c).length()> 254)
                    contactToBeupdate[0].PCR_Welcome_Message__c = String.valueOf(programCommunicationRecs[0].Program_Communication__r.Welcome_Message__c).substring(0, 254);
                else 
                    contactToBeupdate[0].PCR_Welcome_Message__c = String.valueOf(programCommunicationRecs[0].Program_Communication__r.Welcome_Message__c);
                
                contactToBeupdate[0].PCR_Buyer_Logo_Url__c = programCommunicationRecs[0].Program_Communication__r.Logo_Public_Url__c;
                
                 
                contactToBeupdate[0].From_Email__c = programCommunicationRecs[0].Program_Communication__r.From_Email__c;
                contactToBeupdate[0].Reply_to_Email__c = programCommunicationRecs[0].Program_Communication__r.Reply_to_Email__c;
            }
        }

        
        System.debug('TESTER DEBUGGER1');
        if(contactToBeupdate.size() > 0){
            update contactToBeupdate;  
        }
        

        List<String> response = new List<String>();
        System.debug('TESTER DEBUGGER2');
        response.add('Updated Successfully');
        System.debug('TESTER DEBUGGER-PRE-FUTURE');
        return response;
        
    }
   
    @future(callout=true) 
    public static void pardotCallout(String contactId) {
        String returnedResponseFromPardot = Http_Utility_Pardot.pardotCreateProspect(new Set<Id> {contactId});
        System.debug('TESTER DEBUGGER-POST-FUTURE');    
         }
}
ANUTEJANUTEJ (Salesforce Developers) 
Hi Leo,

I think this is the same question that you have mentioned below is the link to the thread:

>> https://salesforce.stackexchange.com/questions/324068/call-a-future-method-with-the-process-builder

I think as per the comment it looks like the issue is resolved, can you mark this as best answer so that it can be accessible to others in the future in case if they face a similar issue.

Thanks.