Created
August 15, 2016 13:42
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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