You need to sign in to do that
Don't have an account?
AntonPavlov
Help solve. Count of created My Task records must be tracked increment the value on related User (owner) record using Trigger
trigger countTack on MyTask__c (after update) {
List<MyTask__c> myTask = [SELECT Id,(SELECT Id,CountMyTask__с FROM Contact) FROM MyTask__c WHERE Id IN :Trigger.New];
for(MyTask__c my :myTask){
List<Contact> contactList = my.Contacts;
my.CountMyTask__c = contactList.size();
}
}
Dont work
List<MyTask__c> myTask = [SELECT Id,(SELECT Id,CountMyTask__с FROM Contact) FROM MyTask__c WHERE Id IN :Trigger.New];
for(MyTask__c my :myTask){
List<Contact> contactList = my.Contacts;
my.CountMyTask__c = contactList.size();
}
}
Dont work
Since MyTask__c is a child to Contact, The field Name will Contact__c
All Answers
You can achieve the same by using Roll-Up Summary field. No need for the trigger.
Roll-Up Summary does give you option for the condition
Since MyTask__c is a child to Contact, The field Name will Contact__c
Abdul Khatri, thanks for the help