Last active
November 3, 2018 15:40
-
-
Save cynthiabellmcgillis/f9178c7bd2ba02ea1a611a531fdd15c0 to your computer and use it in GitHub Desktop.
Second attempt, now with no switch statements!
This file contains 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
trigger DateLogicOpp2 on OpportunityLineItem (before insert, before update) { | |
for (OpportunityLineItem oli :Trigger.new) { | |
if(oli.ServiceDate !=null){ | |
DateTime startDate = DateTime.newInstance | |
(oli.ServiceDate, Time.newInstance(12,0,0,0)); | |
if (oli.Materials_Due_2_Weeks__c) { | |
oli.Materials_Due_Date__c = oli.ServiceDate - (Integer.valueOf(startDate.format('u')) + 11); | |
} else { | |
oli.Materials_Due_Date__c = oli.ServiceDate - (Integer.valueOf(startDate.format('u')) + 4); | |
} | |
oli.Internal_Due_Date__c = oli.Materials_Due_Date__c.addDays(-2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment