You need to sign in to do that
Don't have an account?
Dritter
else if statement not working
We have a map which compares any updates on an account to what was previously there, and then returns true or false. During testing, I'm able to get to return true through the first If statement (line 31), but I can't see to get it to return anything for the Else If statement (line 37). Any ideas?
public without sharing class accountServices{ Map <Id, Account> oldAccs; Map <Id, Account> newAccs; public accountServices (Map <Id, Account> newTriggerAccs, Map <Id, Account> oldTriggerAccs) { oldAccs = oldTriggerAccs; newAccs = newTriggerAccs; system.debug ('Old accounts' + ' ' + oldtriggerAccs); system.debug ('New accounts' + ' ' + newTriggerAccs); } public static boolean isChanged (account newacc, account oldacc) { Account oldAccs = oldacc; Boolean isChanged = (oldAcc.program_of_interest__c == null && newacc.program_of_interest__c != null) || (oldAcc.program_of_interest__c != null && newacc.program_of_interest__c == null) || !(oldAcc.program_of_interest__c.equals(newacc.program_of_interest__c)); if (!ischanged) { isChanged = (oldacc.expected_test_date__c == null && newacc.expected_test_date__c != null) || (oldacc.expected_test_date__c != null && newacc.expected_test_date__c == null) || !(oldacc.expected_test_date__c == newacc.expected_test_date__c); system.debug ('Result 3' + ' ' + isChanged); } else if (!ischanged) { isChanged = (oldacc.expected_prep_start_date__c == null && newacc.expected_prep_start_date__c != null) || (oldacc.expected_prep_start_date__c != null && newacc.expected_prep_start_date__c == null) || !(oldacc.expected_prep_start_date__c == newacc.expected_prep_start_date__c); system.debug ('Result 4' + ' ' + isChanged); } return isChanged; } ........transformation code
Try below code and let me know if it works.
Best Regards,
-Vivek