You need to sign in to do that
Don't have an account?
Kumar David
Trigger to prevent creating task if Account Type is Bill to Customers
I need to put validation on Task so that Task cannot be created for Accounts other than "Sold to Customer" and "Prospect Customer". Currently Task can be created even for "Bill to Customer". There is no option to create a validation rule with task hence I need to have Before insert and before update Trigger. (Type is a picklist in Account that has value: Sold to Customer, Prospect Customer, Bill to Customer)
trigger TaskCanbeCreatedforSoldtoOnly on Task (before insert, before update) {
for (Task t: Trigger.new){
if(t.Account.Type== 'Bill To Customer') {
t.addError ('Please select the Sold to Customer');
}
}
}
Thank you
trigger TaskCanbeCreatedforSoldtoOnly on Task (before insert, before update) {
for (Task t: Trigger.new){
if(t.Account.Type== 'Bill To Customer') {
t.addError ('Please select the Sold to Customer');
}
}
}
Thank you
Try this code:-
There might be some typo errors please check once.
Thanks
Anil.B
All Answers
Try this code:-
There might be some typo errors please check once.
Thanks
Anil.B
Very impressed, not even typo error. It worked like a charm. I believe we need test class for this right? Will be provide me some guidance for writing a test class. Thank you
Thank you for your suggestion.