You need to sign in to do that
Don't have an account?
Ghanesan
Restrict Parent Account to create an opportunity - Getting Error on Trigger
Getting Error on Trigger - Unexpected Token 'Account.Parent.Id'
Here is my Code:
trigger RestrictParentAccount on Opportunity (before insert){
list<Opportunity> Opp = new List<Opportunity>();
For(Opportunity Opp:trigger.New){
List<Opportunity> OptyAcc = [Select id From Opportunity WHERE AccountId = Account.Parent.Id];
{
If(OptyAcc.size() > 0){
opp.AddError('Opportunity Cant be created by Parent Account');
}
}
}
}
Here is my Code:
trigger RestrictParentAccount on Opportunity (before insert){
list<Opportunity> Opp = new List<Opportunity>();
For(Opportunity Opp:trigger.New){
List<Opportunity> OptyAcc = [Select id From Opportunity WHERE AccountId = Account.Parent.Id];
{
If(OptyAcc.size() > 0){
opp.AddError('Opportunity Cant be created by Parent Account');
}
}
}
}
try with below code.
If this helps, Please mark it as best answer.
Thanks!!
All Answers
try with below code.
If this helps, Please mark it as best answer.
Thanks!!
Field: Account Name: Account Name
Operator: Equals
Value/Field: Field - Account Name: Parent Account: Account Name