You need to sign in to do that
Don't have an account?

limit or bulkify the apex trigger
Hello gurus,
the below apex trigger i guess can hit the governor limits and may be be optimized for bulk updates,
Any changes you would recommend? thank you !
---------------------------------------------------------------------------------------------
trigger abc on abc__c (after insert, after update) {
for(abc__c project : Trigger.New)
{
List< Project_Task__c> tasklist = new List< Project_Task__c> (
[SELECT id, name, IsComplete__c FROM Project_Task__c
WHERE (name LIKE '%big deal Call%'
AND IsComplete__c = FALSE
AND abc__c = :project.id]
);
for (Project_Task__c task : tasklist)
{
task. IsComplete__c = true;
}
update tasklist;
}
}
----------------------------------------------------------------------------------------------------
the below apex trigger i guess can hit the governor limits and may be be optimized for bulk updates,
Any changes you would recommend? thank you !
---------------------------------------------------------------------------------------------
trigger abc on abc__c (after insert, after update) {
for(abc__c project : Trigger.New)
{
List< Project_Task__c> tasklist = new List< Project_Task__c> (
[SELECT id, name, IsComplete__c FROM Project_Task__c
WHERE (name LIKE '%big deal Call%'
AND IsComplete__c = FALSE
AND abc__c = :project.id]
);
for (Project_Task__c task : tasklist)
{
task. IsComplete__c = true;
}
update tasklist;
}
}
----------------------------------------------------------------------------------------------------
There are a few mistakes in the Trigger.
I have modified and commented to explain what is done.
Please find below the trigger:
Please let me know if this helps.
If yes, please mark the Question as Solved.
Thanks and Regards,
Anirudh Singh