[SalesForce] Sending a SOAP web-service for each Lead insert

I have a requirement where I have to send out a web service to a third party system every time a Lead is inserted. I can do it by calling the web service via trigger. However I want to make sure that one lead information is going per web service call i.e. one lead per SOAP envelope. (This is how the third party wsdl accepts Leads).

I was thinking of creating multiple web-service call within the trigger however I will be hitting governor limits left and right.

Lead's will be added to Salesforce one at a time. Will this restrict inert trigger to have only one lead record or there is still a possibility of having multiple lead records in the trigger list?

Best Answer

If Leads are added one by one then the trigger size will always be 1.

You could build a check into the trigger to e.g. block batch size larger than 1.

Alternatively, you could maximize the batch size to 10, since that is the max amount of callouts in 1 transaction. You could even make it 100 if you really want to, because you can start 10 @future contexts in 1 transaction, each of which can do 10 callouts.

Best practice, however, is to ask third party webservices to be batch-proof.

Related Topic