0

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...This is the clone button

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

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

5
  • Does this help? salesforce.stackexchange.com/questions/98983/…
    – Eric
    Commented May 18, 2020 at 21:32
  • It's promising but this would require a new button or link? What if I just want to override the standard clone button?
    – Colby Flye
    Commented May 18, 2020 at 21:37
  • "before I click save after clicking clone" do you mean you have an intermediate page before the actual save? Commented May 19, 2020 at 4:00
  • What is the problem you are experiencing? What happens when you use the button? Does it clone? Does it have the field populated after clone?
    – icebird76
    Commented May 19, 2020 at 4:22
  • Sorry I'm stills stumped I added some visuals. I basically want that same view after I click clone and have some fields prefilled out.
    – Colby Flye
    Commented May 19, 2020 at 16:56

0

You must log in to answer this question.

Browse other questions tagged .