You need to sign in to do that
Don't have an account?
Siddharth Lakhotia
Apex Trigger to restrict the change in value of a lookup field , once the record is cloned
HI,
I need to write an apex trigger, that restricts the account name field on the orders object to be changed, after the record has been cloned.
Can somebody help me with this
I need to write an apex trigger, that restricts the account name field on the orders object to be changed, after the record has been cloned.
Can somebody help me with this
Ok..
Meanwhile, can you help me know, if I am going right way
trigger PreventChangeOfAccountName on Order (before insert) {
list <order> ord = new list <Order>();
for (Order o : trigger.new){
If ( o.IsCloned__c = TRUE && ISCHANGED(o.AccountId))
{
}
}
}
I have written this code, however , It is not allowing me to save the record , even before cloning. Can you help me explain why
trigger PreventChangeOfAccountName on Order (before update) {
list <order> ord = new list <Order>();
for (Order o : trigger.new){
If ( o.IsCloned__c = TRUE && o.AccountId != null && Trigger.oldMap.get(o.id).AccountId != null)
{
o.addError('Account name for Cloned Records cant be changed');
}
}
}