• Ruthvik K 5
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hello,
after several attemts, I have tried to import from my developer sandbox just ONE custom class, to check if the problem can be an out of memory. Again in this case, with just one apex class, i've got the java heap error for OutOfMemory.
I've found different answers about this kind of problem for DataLoader but not in EclipseIDE.
Does anyone have a possibile answer or solution?

Best regards

Rossella
Ok guys I've got a humdinger here. I have a visualforce page (Session__c) that has a controller extension to update related fields on another object (Account). On the visualforce page I also have a command button using the URLFOR syntax to create a record of another object type (Patient__c). When I reference the fields in the controller extension on the visualforce page and try to create the new record (Patient__c) it doesn't recognise the default field values i.e. checkbox ticked. When I remove these fields from the visualforce page code the field default values are recognised once more.The page is for a custom object called Session__c with an extension to update fields on Account with an apex:CommandButton to create a new Patient__c record. I can't replicate it in our sandbox environment either!

 
Hi everyone

I am having an issue with my code that I should not get. I definitely have more than 10,000 opportunities/accounts in production but my code should only be updating the opportunities related to the account of the event I am inserting. I am getting this error when trying to insert the event on an account with less than 20 related opportunities. Any help is appreciated thanks.

Apex Trigger: 
trigger EventTrigger on Event (before insert, before update) {
    if(Trigger.isInsert){
        list<Event> CSTIMPList = new list<Event>();
        for(Event evnt : trigger.new){
            if(evnt.Implementation_App_Type__c != null && evnt.System_Admin_Over_Ride__c != 'Mark Complete App Date'){
                if(evnt.Implementation_App_Type__c == 'CST'){
                    CSTIMPList.add(evnt);
                }
            }
        }
        if(CSTIMPList.size() > 0 && CSTIMPList != null){
            Event_HDL.updateimpdateCST(CSTIMPList);
        }
    }
}

Apex Class:
public class Event_HDL {
	public static void updateimpdateCST(Event[] evnts){
			List<Opportunity> OppList = new list<Opportunity>();
			List<Account> relatedacclist = new list<Account>();
			//map the Opportunity record
			Map<Id, List<Event>> oppIds = new Map<Id, List<Event>>{}; 
			for(Event evnt : evnts){
				oppIds.put(evnt.WhatId, new list<Event>());
				oppIds.get(evnt.WhatId).add(evnt);
			}
			//map the account
			Map<Id, List<Opportunity>>  soaIds= new Map<Id, List<Opportunity>>{};
			Map<Id, List<Opportunity>>  accIds= new Map<Id, List<Opportunity>>{};
			for(Opportunity opp : [Select Id, AccountId, Implementation_Appointment_Date__c,
								   Account.Regarding_Review_FP__c, Account.Regarding_Review_Super__c, Account.Regarding_Review_ROA__c from Opportunity where Id in: oppIds.keySet()]){
				soaIds.put(opp.Account.Regarding_Review_FP__c, new list<Opportunity>());
				soaIds.put(opp.Account.Regarding_Review_Super__c, new list<Opportunity>());
				soaIds.put(opp.Account.Regarding_Review_ROA__c, new list<Opportunity>());
				soaIds.get(opp.Account.Regarding_Review_FP__c).add(opp);
				soaIds.get(opp.Account.Regarding_Review_Super__c).add(opp);
				soaIds.get(opp.Account.Regarding_Review_ROA__c).add(opp);
				accIds.put(opp.AccountId, new list<Opportunity>());
				accIds.get(opp.AccountId).add(opp);
			}
			//update the related account with the new imp app date
			for(Account acc : [Select Id from Account where Id in: accIds.keySet()]){
				for(Event evnt : evnts){
					acc.CST_Implementation_Appointment_Date__c = evnt.StartDateTime;
				}
				relatedacclist.add(acc);
			}
			if(relatedacclist.size() > 0 && relatedacclist != null ){
				update relatedacclist;
			}
			//update all cst soas and recommendations(only from the latest review) off the back of them with the new imp app date
			for(Opportunity opp : [Select Id from Opportunity where Related_SOA__c in: soaIds.keySet() OR Id in: soaIds.keySet()]){
				for(Event evnt : evnts){
					opp.Implementation_Appointment_Date__c = evnt.StartDateTime; 
					opp.Trust_Deed_Date__c = evnt.StartDateTime;
					opp.Trust_Deed_Appointment_Date__c = evnt.StartDateTime;
				}
				OppList.add(opp);
			}
			
			
			//update the opportunities
			if(OppList.size() > 0 && OppList != null){
				update OppList;
			}
			
			
	}
}