function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cathie DonohueCathie Donohue 

Need to be able to clone a case and populate original case number on newly cloned case

Best Answer chosen by Admin (Salesforce Developers) 
sandeep@Salesforcesandeep@Salesforce

then it is fine.. Thanks for clarification.

All Answers

Sgt_KillerSgt_Killer

If you wanna populate the parent Case number on a cloned case field try the below approach :-

 

Have a custom clone button(URL) which would send value to fields through url parameters .
 
essentially in url u have to specify something like this

/{!Case.Id}/e?clone=1&00N80000002voCf={!Case.CaseNumber}

Where the 00N80000002voCf is the field id
Cathie DonohueCathie Donohue
Thank you for the suggestion. Is there someone that can help me get this into our sandbox ? I've never done this type of coding. Or is there an article? Plus we need to add another criteria: Record type = 'End client'.


Cathie Donohue | Sales Support Specialist II, MPAY Inc.| o 704-900-0338
Sgt_KillerSgt_Killer

Try following the below mentioned steps -)

 

1. Create a custom text field on the case object to capture the parent clone case number.

2. Create a Visualforce page as shown below

 

<apex:page standardController="Case" extensions="CloneCaseController" action="{!redirect}" >
</apex:page>

 

3. Modify your extensions code as below

public class CloneCaseController {

    public CloneCaseController(ApexPages.StandardController controller) {

    }
    
    public PageReference redirect(){
            
        String Id = ApexPages.CurrentPage().getParameters().get('id');
        PageReference pageref;
       

       Case c = [select Id, CaseNumber from Case where Id = :Id limit 1];
        
        pageref = new PageReference('/'+Id+'/e?clone=1&retURL=%2F'+Id+'&00Ni0000008O7dq='+c.CaseNumber+'&RecordType='+EndClient Id+'&nooverride=1');
       
        return pageref;        
    }

}

 

If you still needed help with implementing it, kindly reach me at redoxmsec@gmail.com

 

Sgt_KillerSgt_Killer

In the above post

 

pageref = new PageReference('/'+Id+'/e?clone=1&retURL=%2F'+Id+'&00Ni0000008O7dq='+c.CaseNumber+'&RecordType='+EndClient Id+'&nooverride=1');

 

the bold id is the new field id which was created to capture the case Number.

 

Missed one more step in the above post
.. :(

 

4. Override the standard Clone button with the above mentioned VF page.

sandeep@Salesforcesandeep@Salesforce

Thanks for suggesting good approach but please make sure will that new record get saved properly or not ? because I doubt newly clonned record will not get saved with same case number which other case is already having.

Cathie DonohueCathie Donohue
Clarification: We only want to reference the original case # as a field in the Newly cloned case.

Cathie Donohue | Sales Support Specialist II, MPAY Inc.| o 704-900-0338
sandeep@Salesforcesandeep@Salesforce

then it is fine.. Thanks for clarification.

This was selected as the best answer
Cathie DonohueCathie Donohue

We have successfully created the custom button in the case object. Now we need the attachments from the original case to copy to new case.  I heard that this can be done via "trigger".   The info below is the url content source.  Can this be done?

 

https://mpay.force.com/PartnerPortal/{!Case.Id}/e?clone=1&00N3000000BiccE={!Case.CaseNumber}&CF{!Case.AccountId}_lkid=&CF{!Case.ContactId}_lkid=&CF{!Case.AccountId}=&CF{!Case.ContactId}=

Cathie DonohueCathie Donohue

We are in need of the case attachements to copy over to the newly cloned case. This is a custom button built with your suggestion. Can you please respond?

 

 

https://mpay.force.com/PartnerPortal/{!Case.Id}/e?clone=1&00N3000000BiccE={!Case.CaseNumber}&CF{!Case.AccountId}_lkid=&CF{!Case.ContactId}_lkid=&CF{!Case.AccountId}=&CF{!Case.ContactId}=