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
Siddharth LakhotiaSiddharth Lakhotia 

How do I restrict the change of lookup field, after the record is cloned


This change pertains to the Orders object.

It has an account name lookup field on it. Once the order is validated or reduced, user gets the option to clone the record. 

The idea behind cloning is to create a duplicate offer copy under same account.

Hoeever, After cloning, user sometimes end up doing regression and change the account name. I am tryinf to put a validation rule , that helps me restrict the change , But i want it to work , once once the order is cloned.

Below is the validation rule written. Please propose changes if any?

PRIORVALUE(AccountId) <> "", 
ISCHANGED( AccountId) 

Do I need an Apex trigger for the same
Gaurish Gopal GoelGaurish Gopal Goel
Hi Sidharth,

In this formula, PRIORVALUE and ISCHANGED won't work because cloned record is a new record not an existing one. So there is no prior value and nothing to compare that the value has been changed or not.

So you will have to write an apex trigger for this requirement. Or you can create a VF page and override the clone button, in the vf page you can make the account field read only.

Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue. Thanks.

Siddharth LakhotiaSiddharth Lakhotia
Hi Gaurish,

Can you help me in writting the trigger for this.


Siddharth L.
kamala swarnalathakamala swarnalatha

In which object you want the validation rule?

In Account or Order object.

Kindly let it know!

Sweet Potato Tec.
Siddharth LakhotiaSiddharth Lakhotia
In orders object. I don't think validation rule will work.. Can you help me with an apex trigger instead