+ Start a Discussion
JGJGJGJG 

Callback to external url on state change or new lead

Hey there, I'm a web developer working with a salesforce developer. I have limited knowledge of SF but was hoping someone could help me point the developer we're working with in the right direction. 

Currently, we have a cron set up on our site every 30 minutes that uses the SOAP api to query 12 fields for around ~500 records to check for status changes due to new leads. This is super inefficient and also means that we are in some cases working with 29 minute old data that is problematic when course registrations are full but continue to allow registrations. 

If we could do away with our cron and instead have a script on our server be hit any time a new lead comes in that would prevent us from having to run a cron every 30 minutes to check 500 courses (many of which haven't changed since the last time). 

Here's what we're hoping is possible.

New lead comes in for a particular course number. 
SF hits https://ourUrl.com/new-lead.php?course_number=12345
We use the SOAP api to query course #12345 for the updated info. 

From looking through the docs and forums it seems like he should be able to accomplish this using triggers, future methods and/or outbound messaging. Am I pointing him in the right direction? 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers.htm#!
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm#!
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_om_outboundmessaging.htm#!
Ramesh DepaiahRamesh Depaiah
You can use apex triggers on lead after insert 
Something like this 

trigger LedOpty on Lead (after insert) {
    List<string> courseIds=new List<string>();
    for(Lead led : trigger.new ) {
        //get all courseids from the leads
        courseIds.add(led.courseId);
    }
    
    if(courseIds.size()>0)
    {
       // Now call SOAP api to query course 
    }
}

I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D