You need to sign in to do that
Don't have an account?
Ewa Fryst
validation rule trigger
HI All,
I would like to prevent a user from creating a task against transactional accounts (Account Record Type = TransactionalAccount). So all the other Account records types are fine, just transactional should not have tasks. I found the trigger below. Could anyone change it for me with the Record type instead of the Type picklist? I will also need one like that for Events. I would appreciate your help.
Many thanks
Ewa
trigger TaskCanbeCreatedforSoldtoOnly on Task (before insert, before update) { set<id>accids=new set<id>(); for(task t:trigger.new){ accids.add(t.whatid); } if(!accids.isempty()){ List<Account>lstacc=[select id,Type from account where id in:accids AND Type=:'Bill To Customer']; Map<id,String>mapofaccts=new Map<id,string>(); for(account acc:lstacc){ mapofaccts.put(acc.id,acc.Type); } for(task t:trigger.new){ if(mapofaccts.containsKey(t.whatid)){ t.addError ('Please select the Sold to Customer'); } } } }
I would like to prevent a user from creating a task against transactional accounts (Account Record Type = TransactionalAccount). So all the other Account records types are fine, just transactional should not have tasks. I found the trigger below. Could anyone change it for me with the Record type instead of the Type picklist? I will also need one like that for Events. I would appreciate your help.
Many thanks
Ewa
trigger TaskCanbeCreatedforSoldtoOnly on Task (before insert, before update) { set<id>accids=new set<id>(); for(task t:trigger.new){ accids.add(t.whatid); } if(!accids.isempty()){ List<Account>lstacc=[select id,Type from account where id in:accids AND Type=:'Bill To Customer']; Map<id,String>mapofaccts=new Map<id,string>(); for(account acc:lstacc){ mapofaccts.put(acc.id,acc.Type); } for(task t:trigger.new){ if(mapofaccts.containsKey(t.whatid)){ t.addError ('Please select the Sold to Customer'); } } } }
Hi Ewa,
Please use the below trigger:
Task:
Event:
Thanks,
Maharajan.C
All Answers
Hi Ewa,
Please use the below trigger:
Task:
Event:
Thanks,
Maharajan.C
That works perfectly. Thank you so much! I appreciate it.
Ewa