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
sean_homelesssean_homeless 

Using most recent record value as default on new record

I have created a custom object that has a pick list field. I would like to have the default value of the pick list be the value that was selected from the most recently created record.

 

For example:

 

Object1.Record1.value = X (a pick list field)

 

When I create a new record in Object1 called Record2 the default value in that field must be X if that is the most recently created record.

 

Can anyone help with this?

Best Answer chosen by Admin (Salesforce Developers) 
fifedogfifedog

by default this isn't doable. This would require a trigger to be created where on create it would find the most recent record and take that value and set it.

 

Have you thought about using clone?

All Answers

fifedogfifedog

by default this isn't doable. This would require a trigger to be created where on create it would find the most recent record and take that value and set it.

 

Have you thought about using clone?

This was selected as the best answer
sean_homelesssean_homeless
Thanks! I am busy exploring cloning. I will give my feedback shortly...
sean_homelesssean_homeless

Cloning does what we want!

The only down side is that you have to do a manual search for the latest record. Users might chose the wrong one(by accident) and not use the correct data. We will try and work around this.

 

I am not too familiar with writing code in Salesforce and so will have to explore triggers at a later stage...

 

 

fifedogfifedog

You may want to look at a couple of consultants that may be able to right a this trigger for you.  I know of one guy that charges a flat rate of per trigger, $600. That's my coder, there is another group I use that more lightwieght which only charges around 95 per hour.  They should be able to do this.

 

What needs to be done is on new, is have a query return the latest record based on created date and set the picklist value of the new record to the returned record.