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
Force2b_MikeForce2b_Mike 

Field value being reset to 'Default' on Cloned Opportunity

I have a custom field on the Opportunity object that defaults to a value of 1, however that value is updated through other processes during the lifecycle of the Opportunity.

 

What I've found, though is that when the Opportunity is cloned the field value gets reset back to 1 instead of keeping the current value that the original Opportunity had (it was 5). Is there a way to prevent this from happening when cloning an Opportunity?

 

Thanks,

 

Mike 

werewolfwerewolf
When you look at that field in Setup->Customize->Opportunity->Fields, is there a default value set there?  That may be overriding the cloned value.
Force2b_MikeForce2b_Mike

Yes, that is where the field defaults to the value of 1 for new Opportunities. However, if the field is updated to a new value at a later point, why would Cloning the Opportunity reset the value back to 1? Shouldn't Cloning keep the current value?

 

 

Mike

werewolfwerewolf
I guess you would think so, I'm not really sure why the default is overriding the clone.  One thing you could do, anyway, is remove that default and set it with a workflow rule that only fires when the opportunity is created and when that field is empty.  That would have the same effect, and would probably make your clone work.
Force2b_MikeForce2b_Mike

What I have figured out is that the field value is only reset if the field is not displayed on the page layout. If I place the field on the Page Layout, the value is retained. If I remove the field, the value is reset. My problem is that this is supposed to be a hidden field used by an Apex class for updates.

 

How can I get SalesForce.com to retain the field value when cloning even if the field is not on the Page Layout?

werewolfwerewolf
Ah yes.  What the "clone" button really does is copy the field values to a new object edit page, therefore anything not on that page will not get cloned.  If you want to hide that field value, your options are either to make a custom Apex button that does a "deeper" clone or to expose that field on the edit page.
Force2b_MikeForce2b_Mike

I had a feeling that was the case, but I was trying very hard to not rewrite the Clone functionality. Guess I don't have a choice. Luckily there are some good code samples out there for this so I don't need to start it from scratch.

 

Thanks your help.

 

Mike