0
votes

I am trying to create an APEX class in Salesforce which sends an SMS. This is called from a Lead Trigger.

I want to pass a 'Lead' into the method but get the following error

"Unsupported parameter type SOBJECT:Lead"

My declaration looks like this.

global   class SMS_Services {

    @future (callout=true)  
    public static void SendTestDriveReminder(Lead l){

    }
}
1

1 Answers

2
votes

This is because you have annotated the method as @future future methods can only accept primitive parameters. So you would need to change the parameter type to Id for example:

@future (callout=true)  
public static void SendTestDriveReminder(Set<Id> leadIds)

The important thing to note is that I have recommend you change your parameter from a single record to a set of Id's this is because you should be bulkifying your trigger

trigger LeadTriggerExample on Lead (after insert, after update) {
    Set<Id> leadIds = new Set<Id>();
    for(Lead l : Trigger.new) {
        if(/*Certain Criteria is met*/) {
            leadIds.add(l.Id);
        }
    }
    SMS_Services.SendTestDriveReminder(leadIds);
}

You only get a small amount of future methods each day, you need to use them sparingly