+ Start a Discussion
smagee13smagee13 

Call method from another method

I have a slight dilemma that Im hoping you call all help me with.  I have a need to call a method from another method, but am not sure how to do so. 

I need the save method to update my custom object before I can have the getupdClaseList method execute successfully.  Both are in the same class, as an extension the controller on a VisualFoce page. 

 

What I would like to happen is that the getupdCaseList method is called after the user clicks the save button (Save method).


Any ideas/tips?

 

 Save method

 

// Save method public pagereference saveChanges() { update myProject; //return null; PageReference pageRef = new PageReference('/apex/editNewProject?id='+myProject.Id); pageRef.setRedirect(true); return pageRef; }

 

 getupdCaselList Method

 

// Calc new days public List<Case> getupdCaseList(){ if(myProject.Id<>Null){ myCaseList = [select Id, Date_Du__c, Internal_Date_Due__c from Case where Project__c = :myProject.Id]; // Set date veriables OCD= myProject.Original_Completion_Date__c; TCD= myProject.Target_Completion_Date__c; // loop through and update case details system.debug(OCD); system.debug(TCD); dayOffset = OCD.daysBetween(TCD); system.debug(dayOffset); for(Case myCaseListItem:myCaseList) { Case newCase = myCaseListItem; newCase.Date_Du__c = myCaseListItem.Date_Du__c + dayOffset; newCase.Internal_Date_Due__c = myCaseListItem.Internal_Date_Due__c + dayOffset; upsert newCase; } //for loop } // myClaseList select return null; } // getmyCalseList method

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
AlsoDougAlsoDoug

Unless I am misunderstanding something (it is Monday) you should need to call the getupdCaseList method in the saveChange method.

 

// Save method public pagereference saveChanges() { update myProject; //return null; PageReference pageRef = new PageReference('/apex/editNewProject?id='+myProject.Id); pageRef.setRedirect(true); //NEW LINE List<Case> myCaseList = getupdCaseList();

 

return pageRef; }

 

All Answers

AlsoDougAlsoDoug

Unless I am misunderstanding something (it is Monday) you should need to call the getupdCaseList method in the saveChange method.

 

// Save method public pagereference saveChanges() { update myProject; //return null; PageReference pageRef = new PageReference('/apex/editNewProject?id='+myProject.Id); pageRef.setRedirect(true); //NEW LINE List<Case> myCaseList = getupdCaseList();

 

return pageRef; }

 

This was selected as the best answer
smagee13smagee13
Thanks, Must be Monday on my end... Worked like a champ
AlsoDougAlsoDoug

Yeah we all days when our brain doesn't work at a 100%.