Last active
July 6, 2016 20:13
-
-
Save johndstein/42ed5cb1b46f212fc02e485548063c21 to your computer and use it in GitHub Desktop.
christar one time gl lock
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
| public void lock() { | |
| List<Donation_Designation__c> dds = getRowsToLock(); | |
| List<Opportunity> ops = getOppList(dds); | |
| System.debug('Size: ' + dds.size()); | |
| for (Donation_Designation__c d : dds) { | |
| d.GL_Lock_Date__c = Date.parse('3/29/2016'); | |
| } | |
| for (Opportunity o : ops) { | |
| o.GL_Lock_Date__c = Date.parse('3/29/2016'); | |
| } | |
| update dds; | |
| update ops; | |
| } | |
| // This just pulls a list of opps from the list of donation designations. | |
| public List<Opportunity> getOppList(List<Donation_Designation__c> dl) { | |
| List<Id> oppIds = new List<Id>(); | |
| for ( Donation_Designation__c d : dl) { | |
| oppIds.add(d.Donation__c); | |
| } | |
| return [ | |
| select GL_Lock_Date__c | |
| from Opportunity | |
| where GL_Lock_Date__c = null | |
| and Id in :oppIds | |
| ]; | |
| } | |
| public List<Donation_Designation__c> getRowsToLock() { | |
| return [ | |
| select Id, | |
| Donation__c | |
| from Donation_Designation__c | |
| where Donation_StageName__c = 'Posted' | |
| and Designation__c != null | |
| and GL_Lock_Date__c = null | |
| and DonationDate__c <= 2016-03-29 | |
| limit 1000 | |
| ]; | |
| } | |
| lock(); | |
| select count() from Donation_Designation__c where GL_Lock_Date__c = 2016-03-29 | |
| select count() from Opportunity where GL_Lock_Date__c = 2016-03-29 | |
| select count() | |
| from Donation_Designation__c | |
| where Donation_StageName__c = 'Posted' | |
| and Designation__c != null | |
| and GL_Lock_Date__c = null | |
| and DonationDate__c <= 2016-03-29 | |
| ./node_modules/dataloader/extract.js \ | |
| Donation_Designation__c \ | |
| out/dd.csv \ | |
| "select Id from Donation_Designation__c where Donation_StageName__c = 'Posted' and Designation__c != null and GL_Lock_Date__c = null and DonationDate__c <= 2016-03-29" | |
| select Id, LastModifiedDate | |
| from Donation_Designation__c | |
| where LastModifiedDate < N_DAYS_AGO:1 order by LastModifiedDate desc | |
| select count() | |
| from Donation_Designation__c | |
| where Donation_StageName__c = 'Posted' | |
| and Designation__c != null | |
| and GL_Lock_Date__c = null | |
| and DonationDate__c > 2016-03-29 | |
| //////////////////////////////////////////////////////////////////////////////// | |
| //////////////////////////////////////////////////////////////////////////////// | |
| public void lock() { | |
| List<Donation_Designation__c> dds = getRowsToLock(); | |
| List<Opportunity> ops = getOppList(dds); | |
| System.debug('Size: ' + dds.size()); | |
| for (Donation_Designation__c d : dds) { | |
| d.GL_Lock_Date__c = System.today(); | |
| } | |
| for (Opportunity o : ops) { | |
| o.GL_Lock_Date__c = System.today(); | |
| } | |
| update dds; | |
| update ops; | |
| } | |
| // This just pulls a list of opps from the list of donation designations. | |
| public List<Opportunity> getOppList(List<Donation_Designation__c> dl) { | |
| List<Id> oppIds = new List<Id>(); | |
| for ( Donation_Designation__c d : dl) { | |
| oppIds.add(d.Donation__c); | |
| } | |
| return [ | |
| select GL_Lock_Date__c | |
| from Opportunity | |
| where GL_Lock_Date__c = null | |
| and Id in :oppIds | |
| ]; | |
| } | |
| public List<Donation_Designation__c> getRowsToLock() { | |
| return [ | |
| select Id, | |
| Donation__c | |
| from Donation_Designation__c | |
| where Donation_StageName__c = 'Posted' | |
| and Designation__c != null | |
| and GL_Lock_Date__c = null | |
| and DonationDate__c > 2016-03-29 | |
| limit 1000 | |
| ]; | |
| } | |
| lock(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment