Need: Ability to Clone records, and set a value into a field during the cloning. In my specific case, I want to populate either a Lookup field with the ID of the record cloned from (so passing forward SFID to the new record) or perhaps a URL field similarly.

Currently: My standard for what this would be to create a java-button that performs the clone manually, and fills in any fields during the process.

Any thoughts?

  • Can I "intercept" the clicking of the standard CLONE button and cause some fields to be populated with certain values (unless overwritten during the editing of the new record)?

  • Or do I just need to do the java-button?

  • Or is there something even better I'm not considering?

Thanks! In my case, this is on a Custom Object, if that matters (I doubt it).

  • I would use a VF override to the clone button and do the defaulting in the controller (as well as clearing any values you don't want to carry forward)
    – cropredy
    Mar 14, 2017 at 1:07

2 Answers 2


You'd want to use sObject clone(true, false, true, true) where true preserves the existing Id, timestamps, and any autonumber fields), then assign the new value to the field you want to change before doing your save for the update. You could call this from a button, a before insert trigger or page controller or however you wanted.

  • I like this idea, but am just not savvy enough to understand how I'd implement that into a button - I would assume javascript(?). Do you know of any example-code that would show something as simple as what I want? Pulling a value (id) from the record the button is clicked on, and populating that value "forward" to a new record (in the case of cloning)? I couldn't find an example. :-/ If you have that, great. I'm going to continue to look and try on my own.
    – AMM
    Apr 15, 2015 at 12:59
  • Quick question for you. Do you expect to know in advance which fields you want to change the values on or do you just want to populate the clone and edit the values as needed? I see two different ways of doing this is why I'm asking and the one to use would depend upon your answer.
    – crmprogdev
    Apr 15, 2015 at 14:06

LOL woooah I'm necroposting here but oh well.

You could do a "Create a Record" Quick Action. In Lightning this can be placed as a button that looks like any other, but in Classic it would be an action in the Chatter feed. There is a decent amount of flexibility here, including:

  • Ability to choose which fields go on the clone action layout
  • Ability to pre-define specified fields from the original, or from fixed values
  • Ability to pre-define even fields that are not shown on the layout

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .