I need to prepopulate the Cloned_From__c field on the case when a user clicks the standard clone button, the field should be the case that is being cloned. How do I prefill this field out before I click save after clicking clone?
Here is what I have....
public with sharing class CloneClosedCaseOverrideController {
private ApexPages.StandardController standardController {get; set;}
public Case CaseRecord{get;set;}
public CloneClosedCaseOverrideController(ApexPages.StandardController standardController){
this.standardController = standardController;
CaseRecord = (Case)standardController.getRecord();
}
public PageReference cloneCase(){
Case CaseCloned;
try{
CaseCloned = CaseRecord.clone(false, false, false, false);
CaseCloned.Cloned_From__c = CaseRecord.Id;
insert CaseCloned;
} catch (Exception e){
ApexPages.addMessages(e);
return null;
}
return new PageReference('/'+CaseCloned.Id);
}
}
Here is the VF
<apex:page standardController="Case" extensions="CloneClosedCaseOverrideController"
action="{!cloneCase}">
<apex:pageMessages />
</apex:page>
Feel like I am close here...Thanks in advance!
Edit: I added some visual here...
Here I want this view to still pop up and have a the cloned from field filled out. So I want this view even when I do a override