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
Ashwini SukumaranAshwini Sukumaran 

Populate data from one record to another record

I have a custom object called "Returned Mail". This has a field called "parent record". This is a lookup to Returned Mail record (not itself, a different returned mail record). 
Ex: Test 1 and Test 2 are returned mail records. Test 1 is a lookup on Test 2 and is called as the parent record. When someone creates a new record called Test 3 and tries to set Test 2 as its parent record then, they should be prevented from doing so and the field should populate to Test 1. 

User-added image

User-added image
Best Answer chosen by Ashwini Sukumaran
Abdul KhatriAbdul Khatri
Hi Ashwini,

I believe the value in the lookup you wanted to select are the ones that do not have any Parent Record. If that is the case you can use the filter of the lookup to consider only those values where the Parent Record = '' . This is one way to handle this but if you still wanted through code, we can still do that but as per recommendation this should do fulfil requirement.

User-added image

All Answers

Abdul KhatriAbdul Khatri
Hi Ashwini,

I believe the value in the lookup you wanted to select are the ones that do not have any Parent Record. If that is the case you can use the filter of the lookup to consider only those values where the Parent Record = '' . This is one way to handle this but if you still wanted through code, we can still do that but as per recommendation this should do fulfil requirement.

User-added image
This was selected as the best answer
Ashwini SukumaranAshwini Sukumaran
Hi Abdul,

This works for now. Thank you so much! Appreciate the help.

Regards,
Ashwini