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 

How to call these methods with a trigger ?

I am currently calling this class with a Process Builder. But I can't see the results of the code following the @Future statement. I've looked through debug logs as well as in the Apex Jobs list and cannot find them. Am I unable to see them run because they are following a @Future statement ? Or is it because it's a second method in a class being called by a Process Builder ? Or is there another way I need to try and see it run ? 

Should I be calling the methods individually from a trigger ?

 

public class UpdateContactPCRController {

    @InvocableMethod
    public static String  updateContact(String recordId){        
       
        String contactId = '';       
        
        List<Contact> contactToBeupdate = new List<Contact>();        
        
        if(String.isNotBlank(recordId)){            
            
            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];
            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].Program_Contact_Role_Id__c = recordId;
            }
			List<Program_Communication_Recipients__c> programCommunicationRecs = [Select Id,Name,
					  Program_Communication__r.Program__r.Buyer__r.Name,Receipient__c,                
								  From Program_Communication_Recipients__c Where 
											   Program_Communication__r.Program__c =: programContacList[0].Program_Name__c AND 
											   Receipient__c =: programContacList[0].Id];                                           
					
	
			contactToBeupdate[0].PCR_Welcome_Message__c = String.valueOf(programCommunicationRecs[0].Program_Communication__r.Welcome_Message__c);                                                    
			
			if(contactToBeupdate.size() > 0){
				update contactToBeupdate;  
			}
			pardotCallout(contactToBeupdate[0].Id);
    
			return 'Updated Successfully';
		}
		else{
			return 'some message';
		}
    }
	
	@future(callout=true) 
	public static void pardotCallout(String contactId) {
		String returnedResponseFromPardot = Http_Utility_Pardot.pardotCreateProspect(new Set<Id> {contactId});
		// new treatment here with the returned value included DML operations.
		// further logic if any based on the response you get from Pardot
	}
}
pconpcon
@future calls to generate a seperate debug log whenever they run.  You will want to create a debug log watch entry for the user running the code and you should see a second debug log generated specifically for the future call.
ANUTEJANUTEJ (Salesforce Developers) 
Scheduled apex, future apex, Batch jobs are asynchronous so, it may take some time depending on system load. It creates a separate file for executing and finish calls.
Also, make sure that you have setup debug logs for current logged user in Monitoring > Debug Logs.
 
 You need to set up "User Trace Flags" with debug level for apex:DEBUG, system:DEBUG to see logs.

For additional modules for asynchronous apex, please check the following module: https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex

Please refer below link for the same.

http://salesforce.stackexchange.com/questions/98907/apex-batch-jobs-logs
 
Hope this helps you!

Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
 
Thanks.