Created
January 5, 2016 22:33
-
-
Save kreas/f675c2df327fe2451e42 to your computer and use it in GitHub Desktop.
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
| trigger Opportunity on Opportunity (before insert, before update, after insert, after update) { | |
| set<id> newEvents = new set<id>(); | |
| set<id> updateEvents = new set<id>(); | |
| set<string> changingFields = new set<string>{ | |
| 'Primary_Contact__c', | |
| 'Lead_ID__c', | |
| 'AccountID', | |
| 'Name', | |
| 'StageName', | |
| 'Confirmation_Number__c', | |
| 'Private__c', | |
| 'Meeting_space_required__c', | |
| 'Date_Flexibility__c', | |
| 'Repeat_every__c', | |
| 'ends_on__c', | |
| 'Peak_Block__c', | |
| 'Total_Block__c', | |
| 'share_with_block__c', | |
| 'star_rating__c', | |
| 'distance_from_airport__c', | |
| 'max_exhibit_size__c', | |
| 'max_ballroom_size__c', | |
| 'max_breakout_size__c', | |
| 'priority_rate__c', | |
| 'priority_destination__c', | |
| 'priority_rating__c', | |
| 'priority_weather__c', | |
| 'priority_offsite_amenities__c', | |
| 'priority_distance_from_airport__c', | |
| 'priority_flights_from__c', | |
| 'priority_onsite_amenities__c', | |
| 'priority_hotel_brands__c', | |
| 'City__c', | |
| 'Description', | |
| 'Main_Group_Arrival_Date__c', | |
| 'Length_of_Stay__c', | |
| 'Frequency__c', | |
| 'Destination__c', | |
| 'weather_degrees__c', | |
| 'additional_information__c', | |
| 'direct_flights_from__c', | |
| 'hotel_brands__c', | |
| 'Onsite_Amenities__c', | |
| 'Offsite_Amenities__c', | |
| 'locations__c', | |
| 'Prepopulate__c', | |
| 'Average_Daily_Room_Max__c', | |
| 'Average_Daily_Room_Min__c', | |
| 'Weather_Min__c', | |
| 'Weather_Max__c', | |
| 'Hotel_Visit__c', | |
| 'Property_Summary_Comments__c', | |
| 'Main_Group_Arrival_Date__c', | |
| 'Number_of_Move_In_Days__c', | |
| 'Number_of_Move_Out_Days__c', | |
| //'Total_Contractual_F_B_Guarenteed__c', | |
| 'Catering_Estimated_Spend__c', | |
| 'Number_of_Catering_Events__c', | |
| 'Banquet_Estimated_Spend__c', | |
| 'Banquet_Number_of_Events__c', | |
| 'Restaurant_Estimated_Spend__c', | |
| 'Restaurant_Number_of_Events__c', | |
| 'Offsite_Estimated_Spend__c', | |
| 'Offsite_Estimated_Number_of_Events__c', | |
| 'Room_Grid_Data__c' , | |
| 'Over_Under_Days__c', | |
| 'Ready_for_EG_Review__c', | |
| 'Submitted__c' | |
| }; | |
| set<id> EGReviewTasks = new set<id>(); | |
| list<Task> taskList = new list<Task>(); | |
| if(trigger.isBefore){ | |
| OpportunityService.setAPIFlag(trigger.new); | |
| system.debug(Service.isAPI); | |
| for(Opportunity o:trigger.new){ | |
| system.debug(o); | |
| if(trigger.isUpdate && !Service.isAPI){ | |
| if(o.Submitted__c!=trigger.oldmap.get(o.id).Submitted__c && o.Submitted__c){ | |
| o.Eventa_Status_ID__c=3; | |
| }else{ | |
| o.Eventa_Status_ID__c=1; | |
| } | |
| } | |
| } | |
| if(trigger.isInsert){ | |
| OpportunityService.assignOwner(trigger.new); | |
| OpportunityService.checkDuplicates(trigger.new); | |
| } | |
| }else if(trigger.isAfter){ | |
| if(trigger.isInsert){ | |
| for(Opportunity o:trigger.new){ | |
| if(!Service.isAPI){ | |
| system.debug('New Opp'); | |
| updateEvents.add(o.id); | |
| } | |
| } | |
| }else if(trigger.isUpdate && !System.isFuture()){ | |
| for(Opportunity o:trigger.new){ | |
| system.debug('Changing Opp Boolean:' + Service.isChanging(trigger.oldmap.get(o.id), o, changingFields)); | |
| system.debug(service.isAPI); | |
| if(Service.isChanging(trigger.oldmap.get(o.id), o, changingFields) && !Service.isAPI){ | |
| system.debug('Edited' + o.id); | |
| updateEvents.add(o.id); | |
| } | |
| } | |
| OpportunityService.createTasksforReview(trigger.new, trigger.oldMap); | |
| } | |
| if(!updateEvents.isEmpty() ){ | |
| system.debug('Calling OpportunityService'); | |
| OpportunityService.sendEventsToEventa(updateEvents); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment