You need to sign in to do that
Don't have an account?
pooja chauchan
How to Bulkify a SpecificTrigger?
for (task ta : trigger.new){
id Opportunityid = ta.WhatId;
Opportunity oOpportunity = [select id, Latest_Open_Due_Date__c from Opportunity where id = :Opportunityid LIMIT 1];
if (oOpportunity.Latest_Open_Due_Date__c < ta.ActivityDate ) {
if (ta.Status != 'Completed' ) {
System.debug ('in completed');
oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
//update oOpportunity;
}
}
if (oOpportunity.Latest_Open_Due_Date__c == null) {
if (ta.Status != 'Completed' ) {
oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
//update oOpportunity;
}
}
List <Task> ActiveTask = [select id, WhatId from Task where Whatid = :Opportunityid and status != 'Completed'];
if (ActiveTask.isEmpty()){
oOpportunity.Latest_Open_Due_Date__c = null;
///update oOpportunity;
}
update oOpportunity;
}
id Opportunityid = ta.WhatId;
Opportunity oOpportunity = [select id, Latest_Open_Due_Date__c from Opportunity where id = :Opportunityid LIMIT 1];
if (oOpportunity.Latest_Open_Due_Date__c < ta.ActivityDate ) {
if (ta.Status != 'Completed' ) {
System.debug ('in completed');
oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
//update oOpportunity;
}
}
if (oOpportunity.Latest_Open_Due_Date__c == null) {
if (ta.Status != 'Completed' ) {
oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
//update oOpportunity;
}
}
List <Task> ActiveTask = [select id, WhatId from Task where Whatid = :Opportunityid and status != 'Completed'];
if (ActiveTask.isEmpty()){
oOpportunity.Latest_Open_Due_Date__c = null;
///update oOpportunity;
}
update oOpportunity;
}
All Answers