+ Start a Discussion

Easiest way to kick off some SQL.

I'll start with a disclaimer... I haven't done much APEX, I'm a PHP developer... but I have played with the php API, got in with the force.com IDE,  and have a decent idea about what's going on.


So, what I'm looking for is:

Stage 1: A button that, when click runs something like "Update leads set start_date = tomorrow()+1day, status = 'sent' where status='registered' and start_date <= today() and id = "memberid";

Stage 2: Have that query, without the id=memberid restriction run on a cron job.  Preferably in salesforce, if it'll do that.  Otherwise I can kick it off from my server...


I'm not looking for someone to code this for me, but kinda let me know the best place to implement this.  A visual force page?  A php page on my server that runs the query?  Is there cron functionality in SF?






1) Use a VF page w/ a method action in the page tag that auto-runs upon load.  Then create an Apex controller for the page that has the method to do the work of getting the ID and updating the record.

2) For cron jobs, you can use an ApexScheduler class.  I'm not sure if this is generally available or if you'll have to talk to your rep to have it provisioned.  Might be GA as of this weekend for all servers (NA1, 2,etc)





For Stage 2, there's a new feature called Apex Scheduler being released this weekend - take a look at that in the docs, and that should enable the chron job aspect. If you have high volumes, you may need to combine that with Batch Apex.


For Stage 1, not sure I understand what memberid is - is that a reference to campaign, or a custom field? Having a button call some apex is code is relatively straightforward -if you make the main apex class global, and declare a method within it as a webservice, you can call that from a custom button, or you can a VF page and just call it directly...

global class updateleads {

webService Static void updateallleasd (Lead {} leads) {}