Skip to main content

Firstly, in the trigger, pass the record ID and deletion time to the outboundcall method instead of the entire trigger.old list.

trigger keyfobdelete on Key_Fob_Dispenser__c (before delete) {
    for (Key_Fob_Dispenser__c keyfob : trigger.old) {
        keyfobdeletehandlerclass.outboundcall(keyfob.Id, DateTime.now());
    }
}

Secondly, in the outboundcall method, you need to construct the JSON payload using the record ID and deletion time. Here’s an example of how you can modify the method to include the necessary information:

public class keyfobdeletehandlerclass {
    public static void outboundcall(Id recordId, DateTime deletionTime) {
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://site2gym-dev-1555481187.ca-central-1.elb.amazonaws.com/api/keyfob-management');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json');
        
        // Construct JSON payload with record ID and deletion time
        String jsonBody = '{"recordId": "' + recordId + '", "deletionTime": "' + deletionTime + '"}';
        req.setBody(jsonBody);
        
        // Perform the callout
        // Add your code to send the request and handle the response here
    }
}

I hope this information is helpful for you.

Subscribe For More Updates

 

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!