function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chercher 

Alert after the successful execution of javascript

Hi, 

I am executing the apex job from a detail page button below is the code :

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var url = parent.location.href;
var scr="updateSalesTeamValuesonKeyMessage updatekeys = new updateSalesTeamValuesonKeyMessage(); " +
" database.executebatch(updatekeys); ";
var result = sforce.apex.executeAnonymous(scr);


I want the user to get a message stating "the reqeusted job as completed" after successful execution of the apex job. Let me know if there is a way to do this. 
EnreecoEnreeco
You need to mess with the "AsyncApexJob" SObject (see http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_asyncapexjob.htm ) and filter by field "ApexClassID" to be in the "ApexClass" named "updateSalesTeamValuesonKeyMessage", JobType = 'BatchApex", CreatedById = [CurrentUserId] and Status = 'Completed' and CreatedBy >= lauchDate, where LauchDate is the date taken right before calling the "executeAnonymous" code.
You can do this query looping every X seconds: if you find a record than you're done!

Hope this could help
--
May the Force.com be with you