Skip to content

Instantly share code, notes, and snippets.

@jsullivanlive
Created August 15, 2016 13:42
Show Gist options
  • Save jsullivanlive/7b3c5f80efe2423402fc85e697b1d9eb to your computer and use it in GitHub Desktop.
Save jsullivanlive/7b3c5f80efe2423402fc85e697b1d9eb to your computer and use it in GitHub Desktop.
Run anon apex repeatedly when you have too many records to update in one transaction
var jsforce = require('jsforce');
var conn = new jsforce.Connection({
serverUrl : '',
sessionId : ''
});
var apexBody = `
update [
select id
from task
where IsClosed = true
and WhoId in (
select id
from lead
where convertedcontactid = null
and last_owner_activity_date__c = null
and calls__c > 0
)
and lead__c = null
and activitydate >= last_year
and lastmodifieddate < today
limit 1000
];
`;
function exec () {
conn.tooling.executeAnonymous(apexBody, function(err, res) {
if (err) { return console.error(err); }
console.log("compiled?: " + res.compiled); // compiled successfully
console.log("executed?: " + res.success); // executed successfully
exec ();
});
}
exec();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment