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
eriklangeriklang 

Change field value to blank when clicking the clone button on custom objects.

Is it possible when clicking the clone button on a custom object, to set certain fields to a different value or make them blank?  This would force the user to pick a new date for instance.  I know this can be accomplished by creating a visualforce page, but i was wondering if this can be accomplished thru the UI.

Thanks
Salesforce WizardSalesforce Wizard
Eriklang,

You don't have control over the standard Clone Button. So no, you cannot have other values be blanked.

You do, however, have some options to consider.
  1. You could use a custom button with that does a URL hack to pre-populate fields on the new record page. Be warn, that URL Hacks are not an officially support features.
  2. You could use an Apex Trigger with a custom field to request the "clone" record. 
  3. You could use Visual Flow. This can be called from a custom button and would have a screen that you can guide the user to enter the new value for the specific fields you're concerned about. 
  4. You could use Visual Flow called via Workflow (pilot) or Apex trigger. This wouldn't have any screens, but it would create the record - however it wouldn't take the user to the new record.
  5. You could use Flow with Apex. The flow can be called by a button, display some information on the screen, and Apex can be used to CLONE the record, insert the new record and change any fields that should be changed.
  6. You could use a Visualforce page - which is an option you already know about. IMO you'll be better off using Flow than coding everything with Visualforce and a custom controller

So there are some options to consider. Each has their own pros and cons. The URL Hack could be the easiest method since it has no code involved, but it might not be very viable if you have LOTS of fields to handle. Plus, the URL hack isn't really supported.

The option I would choose would be one of the flow options depending on the specific use case.

Hope this gives you some ideas.

eriklangeriklang
Thanks for info, this is really helpful.